File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes JSTL EL language not resolving Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

JSTL EL language not resolving

Sean Stephens
Ranch Hand

Joined: Oct 25, 2004
Posts: 40
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.

Any idea what I'm doing wrong here?

Thanks.
[ June 22, 2006: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sean Stephens
Ranch Hand

Joined: Oct 25, 2004
Posts: 40
hehe... yeh, the ResultSet is another class - not related to the java.sql ResultSet.

None of the expression language calls are resolving, not just to hte createDate field but others as well. All fields have accessors and mutators.
Sean Stephens
Ranch Hand

Joined: Oct 25, 2004
Posts: 40
even doing the following from sun's jstl example article:

<c:set var="browser" value="${header['User-Agent']}"/>
<tr><td colspan=7><c ut value="${browser}"/></td></tr>

results in the following output to the browser:

${browser}

EL hates me.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

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.
Venkatraman Kandaswamy
Ranch Hand

Joined: Jul 07, 2004
Posts: 120
did you try isElignored="false" ?


--Venkatraman<br />SCJP 1.4<br /><a href="http://kvrlogs.blogspot.com" target="_blank" rel="nofollow">blog</a>
Sean Stephens
Ranch Hand

Joined: Oct 25, 2004
Posts: 40
Env is JBoss 3.2.5 (so Tomcat 5.x) and JSTL 1.1
and I don't think I did that in the web.xml. If you have the syntax for that Bear, please post.

Thanks all

[ November 12, 2004: Message edited by: Sean Stephens ]

[ November 12, 2004: Message edited by: Sean Stephens ]
[ November 12, 2004: Message edited by: Sean Stephens ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

Sean Stephens
Ranch Hand

Joined: Oct 25, 2004
Posts: 40
Sorry Venka, I thought you were making a joke... didn't realize there really was such a property...

Still not working after changing web app to 2.4
[ November 12, 2004: Message edited by: Sean Stephens ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

OK, stripped down to the barest essentials: set up a simple JSP page with the following body:



Until you can get this working, all else is moot.
Sean Stephens
Ranch Hand

Joined: Oct 25, 2004
Posts: 40
heh... Tomcat 5.0.x implementation is a little wonky...

to use JSTL and EL, it is necessary to set the web-app as mentioned above AS WELL AS using this TLD URI

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>

Note, this is the core_rt, not core version...

All is happy now! Thanks for your help.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65



That's a JSTL 1.0 URI. You really should be using JSTL 1.1 rather than 1.0 with Tomcat 5.
Sean Stephens
Ranch Hand

Joined: Oct 25, 2004
Posts: 40
Makes sense Bear, but that just doesn't seem to want to work. Got that solution from a few different web app dev communities.

If I find a way to get it to work with 1.1 I'll post it.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

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
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">

jsp taglib tag:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>


2) web.xml tag:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4" >
jsp taglib tag:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
---------------

The only version of jstl installed is 1.1

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.

Thoughts? Comments?

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

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?

It works like a champ for me:
Tomact 5.0.25 or 5.0.28
web.xml: servlet 2.4
c tld uri: http://java.sun.com/jsp/jstl/core
Sean Stephens
Ranch Hand

Joined: Oct 25, 2004
Posts: 40
Originally posted by Bear Bibeault:
Something must be very odd with your setup. Whose JSTL 1.1 are you using?


jars came out of jwsdp-1.4 release from Sun. I couldn't find the 1.1 jstl release by itself anywhere.

And what exactly happens when you use Servlet 2.4 with the JSTL 1.1 uri of http://java.sun.com/jsp/jstl/core?


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.


It works like a champ for me:
Tomact 5.0.25 or 5.0.28
web.xml: servlet 2.4
c tld uri: http://java.sun.com/jsp/jstl/core


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
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

The rt libraries do not exist in JSTL 1.1 -- they are a JSTL 1.0 artifact.

You should be using the JSTL 1.1 with Tomcat 5 and Servlets 2.4.
Dennis Johnson
Greenhorn

Joined: Jul 31, 2006
Posts: 2
Hi there,

I also get this type of error ("According to TLD or attribute directive in tag file, attribute value does not accept any expressions").

I'm using
IDE: BEA Workshop Studio 3.1.0 (includes JSTL 1.1 & MyFaces 1.1.1)
WebContainer: Tomcat 5.5.17
web_app 2.4

I've reduced the functionality of my page to this:


Strangely, I also get the error when commenting the statement


Only completely erasing this line results in an (empty but) errorless page.

My web.xml:


Any help would be greatly appreciated.

Kind regards,
Dennis
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

It would be better to start your own topic in the JSF forum than tacking it onto a question on the JSTL as you have done.

I'm going to close this topic, Please post a new one in the JSF forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL EL language not resolving
 
Similar Threads
EL not evaluating in td tag
Expression Language not supported in compile time attribute items
DisplayTagLib not working (but it works fine with jstl core lib)
JSTL forEach tag in struts problem
Default JSTL URI can't be resolved