I'm trying to use a c:forEach tag with c ut tags in the body.
The jstl jars are in the webapp, and the taglib directive to import it is there. The c.tld is both in the WEB-INF and in the jstl jar (one of them).
Here is a line for a cell to be rendered: <td>cr. <c ut value="${resultSet.createDate}" /></td>
What appears on the page is: cr. ${resultSet.createDate}
For some reason the jstl expression language portion is not resolving. Also, the forEach tag is not iterating over the contents of the ArrayList, its only going through it once.
You're passing a ResultSet to a JSP page? If so, (putting aside how bad an idea I think that is) there is no getCreateDate() accessor on ResultSet, so no evaluation.
If resultSet is some other class, does it have an accessor for a createDate property? [ November 11, 2004: Message edited by: Bear Bibeault ]
Sounds like EL is not enabled. You didn't mention much about your environment. Tomcat 4? Tomcat 5? JSTL 1.0? JSTL 1.1?
A common reason for this under Tomcat 4 is using the wrong URI for the JSTL tlds. A common reason under Tomcat 5 is that the web app must be declared as a Servelt 2.4 web app in its web.xml to turn on the EL.
Tomcat 5 works very easily with JSTL 1.1 -- you don't need to worry whether you are using the 'rt' version or not since there is no such animal in 1.1.
Under JSP 2.0 (Tomcat 5), the EL and JSTL are no longer tied together; the EL is evaluated by the container, not the JSTL tags.
That's the reason I suggested trying the stripped-down, JSTL-less example that I posted.
I'd suggest getting that working, and then download and replace the JSTL 1.0 with JSTL 1.1. It'll work a lot better for you under Tomcat 5 (JSP 2.0).
Sean Stephens
Ranch Hand
Joined: Oct 25, 2004
Posts: 40
posted
0
Ok, here's the combinations that work:
----------------- 1) web.xml tag: <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
So, the question is whether either one of those are what I should be running on. One is on the latest servlet spec (2.4), but must run on the jstl 1.0 compatible uri, core_rt. The other is on an older servlet spec (2.2) but runs on the jstl 1.1 uri. It does not run with the 2.4 servlet spec on the jstl 1.1 uri.
Something must be very odd with your setup. Whose JSTL 1.1 are you using? And what exactly happens when you use Servlet 2.4 with the JSTL 1.1 uri of http://java.sun.com/jsp/jstl/core?
Do you have any TLD defs in your web.xml, or are you letting Tomcat auto-discover the TLDs?
ok, here's my tests: 1) servlet 2.2, using EL 3+4=${3+4}, no jstl tag spec on page -- The EL phrase is not evaluated, but printed as a literal. 2) servlet 2.4, using EL 3+4=${3+4}, no jstl tag spec on page -- The EL phrase is not evaluated, but printed as a literal. 3) servlet 2.4, using EL 3+4=${3+4}, jstl tag 1.1 spec on page -- EL phrase is evaluated. 4) servlet 2.4, using EL in jstl <c ut> tag, jstl tag 1.1 spec on page -- get the following error. According to TLD or attribute directive in tag file, attribute value does not accept any expressions which says to me the core tag is not defined for use with EL...
Then I noticed my URI is different than yours mine: <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> yours: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
result: everything is coexistent peace and harmony
Do you have any TLD defs in your web.xml, or are you letting Tomcat auto-discover the TLDs?
Yes, currently the Struts tld's and 2 custom ones are defined in web.xml as follows. Please advise if this should be different.
The only thing different going on is I'm using JBoss 3.2.5, which uses one of the Tomcat 5.0x releases... so I wouldn't think things would really be any different...
Thanks for helping me work this out.
Mark Townsend
Greenhorn
Joined: Jun 22, 2006
Posts: 1
posted
0
I am using Tomcat 5.5 and had the exact same issue. I changed the JSTL taglib reference from core to core_rt and everything worked. And I have my web-app set to 2.4.