Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2005

Tip: Looking for answers? Try searching our database.

JSP struts tag error

Thread view: 
P.Hill - 21 Jun 2005 01:28 GMT
I am having trouble getting certain  tags to work.

My struts action places various things in the sessions
(bibliosTotal, biblio1, biblios) The following bare EL work fine.
The scriplet works fine and prints an expected value out.
But the use of the logic:notPresent tag results in the value
not being identified as present, so it also prints a message
despite being in direct conflict with the previous bit of code.

Any suggestions?

Am I not supposed to be trying to mix and match struts tags with
'modern' jstl?

Total Biblios: ${bibliosTotal} </br>
1st bibliography: ${biblio1} </br>
<p>
<%
    out.println( ((List)(session.getAttribute( "biblios" ))).size());
%>
</p>
<p>
<logic:notPresent name="${biblios}" scope="session">
    There are NO biblios (Using logic:notPresent).</br>
</logic:notPresent>

The top of the file contains:
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>

My web.xml contains:
  <taglib>
    <taglib-uri>/tags/struts-logic</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
  </taglib>

jstl.jar, standards.jar and struts.jar (plus many others) are in my
WEB-INF/lib directory.
Wendy Smoak - 21 Jun 2005 02:08 GMT
> <logic:notPresent name="${biblios}" scope="session">
> There are NO biblios (Using logic:notPresent).</br>
> </logic:notPresent>

You've asked it whether there is an object in session scope under the key
[whatever ${biblios} evaluates to].  So, what _does_ ${biblios} evaluate to?

I suspect that you really want this:
    <logic:notPresent name="biblios" scope="session">

But if you've got JSTL, I would suggest using <c:if> instead of
<logic:notPresent>.

Maybe...
<%@ taglib uri="http://java.sun.com/jstl/core"         prefix="c" %>
<c:if test="${empty biblios}">
...
</c:if>

BTW, you don't have to put the tlds in WEB-INF and map them in web.xml.  The
tlds are inside the various .jar files, if you use the correct URI, they
will automatically be located.

Signature

Wendy Smoak

P.Hill - 21 Jun 2005 17:57 GMT
> I suspect that you really want this:
>      <logic:notPresent name="biblios" scope="session">

Yes, I did want the value of the object 'biblios' not the value of the
object pointed to by the value of biblios.
Thanks,

> Maybe...
> <%@ taglib uri="http://java.sun.com/jstl/core"         prefix="c" %>
> <c:if test="${empty biblios}">
>  ...
> </c:if>

That is really the right way, I was just trying all the libs, because
something wasn't working, for example:

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
...
<c:if test="${empty biblios}">
    There are NO biblios (Using c:if).</br>   
</c:if>

Results in:

org.apache.jasper.JasperException: /pages/Biblio.jsp(23,0) According to
TLD or attribute directive in tag file, attribute test does not accept
any expressions
(The c:if is line 23)

> BTW, you don't have to put the tlds in WEB-INF and map them in web.xml.  The
> tlds are inside the various .jar files, if you use the correct URI, they
> will automatically be located.

Maybe that's part of my c: problem.  I have jstl.jar and standard.jar
from the jakarta-taglibs-standard-1.1.2 distribution and all I see are
some classes and a MF file in both.

But the README with the distribtion does say:

"To use this distribution with your own web applications, simply copy
the JAR files in the 'lib' directory (jstl.jar and standard.jar) to your
application's  WEB-INF/lib directory"

I'm running tomcat 5.0.19 and trying to use
jakarta-taglibs-standard-1.1.2 with dates on the jars from October 2004
(which is a little confusing because 1.1 implements the JSP 2.0 spec if
I understand at least this correctly).

When I comment out all of the standard http://java.sun.com/jsp/jstl/
references in my web.xml (despite not seeing any TLDs in the jars), I
get exactly the same error; "attribute test does not accept any expressions"

Any help would be deeply appreciated.

-Paul


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.