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 expressions are not evaluated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL: EL expressions are not evaluated" Watch "JSTL: EL expressions are not evaluated" New topic
Author

JSTL: EL expressions are not evaluated

Marina Popova
Greenhorn

Joined: Jul 20, 2001
Posts: 11
Hello!
I am trying to write a simple test web application using JSTL and encountered the following problem:
JSTL core tags are working fine (like <c ut ...>, <c:forEach...> but the EL expressions are not evaluated. Below is a simple test page that demonstrates the problem:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<html>
<head>
<title>JSTL WISS Preview</title>
</head>
<body bgcolor="#FFFFFF">
<jsp:useBean id="directory"
class="test_wiss_JSTL.WISSDirectoryDataBean" />
<br>
Total number of Files (JSTL): <c ut value="${directory.totalNumFiles}"/>
<br>
Total number of Files (JSP):
<jsp:getProperty name="directory" property="totalNumFiles"/>
<br>
<c:forEach var="i" begin="1" end="5">
<c ut value="${i}"/><br>
</c:forEach>
<c:forEach var="file" items="${directory.fileList}">
<c ut value="${file}"/><br>
</c:forEach>
</body>
</html>
The result (in the browser) is:
Total number of Files (JSTL): ${directory.totalNumFiles}
Total number of Files (JSP): 2
${i}
${i}
${i}
${i}
${i}
${file}
So, as you can see, the <c:xxx> tags work correctly , the usual JSP tags work correctly also and the bean's totalNumFiles value is shown correctly too, but when I try to show the same value using the EL expression (${directory.totalNumFiles} ) - it does not work. Nor does a simple integer value ${i} - not a bean's property...
It seems I'm missing something very obvious - just cannot see it just yet. Any ideas?
I use Tomcat5.0.12. I did try to include the JSTL's jar files (standard.jar and jstl.jar) into my web application's WEB-INF/lib directory, even though they are in the $CATALINA/commons/lib - it did not help.
Thanks!
Marina
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

Marina,
Firstly, when posting code fragments, please be sure to enclose the code with the UBB code tags (the little CODE button below the text area will help you out), and be sure to click 'disable smilies' near the bottom of the form page. This will make your code more easily readable to all.
I haven't had any such problems with the JSTL tags myself, but I haven't had a chance to try anything under Tomcat5 yet either.
One thing to be sure of is that the tld you are using is the c.tld file and not the c-rt.tld. I can't tell from what you posted which you are using.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Marina Popova
Greenhorn

Joined: Jul 20, 2001
Posts: 11
Hi, Bear,
Thanks for the response and sorry about the smileys - I realized that after the message got posted only...
Yes, I do use c.tld, as this is the library that is supposed to support EL. I have the c.tld file in my app's WEB-INF directory.
Any other ideas?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

No need to apologize. You'll just get better responses if people can read the code!
With regards to your original problem, I don't have any other ideas off the top of my head. I'm still in the Tomcat4 world and am having no problems with EL, so I don't know if it's a Tomcat4 vs Tomcat5 issue, or some subtle JSTL setup issue.
Perhaps someone playing around with Tomcat5 (hint, hint) might have some insight.
bear
Marina Popova
Greenhorn

Joined: Jul 20, 2001
Posts: 11
For those who is interested - I have fixed it (or, rather, got a good answer from the JSTL mailing list and it worked!).
The problem was that I used the DTD 2.3 for my web app web.xml file where it should've been DTD2.4:

Marina
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60059
    
  65

Thanks for posting your solution Marina. That was very courteous. I can see that you are going to be a valuable addition to the Ranch!
bear
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL: EL expressions are not evaluated
 
Similar Threads
EL expressions not evaluating
Convert JSTL variable type
Hashtables in JSTL
simple JSTL problem
Unable to read TLD when accessing a JSP