JSP struts tag error

P

P.Hill

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.
 
W

Wendy Smoak

P.Hill said:
<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.
 
P

P.Hill

Wendy said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top