• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSTL: EL expressions are not evaluated

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marina Popova
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic