Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Tomcat 5.5.7 and JSTL setup exception.

843836Apr 27 2005 — edited Apr 27 2005
Hello,

I've set up my Mac with tomcat 5.5.7 using the compat patch. I've also set up my webapp to use spring. I've copied spring.jar, jstl.jar and standard.jar to my ./tomcat/common/lib directory. However when I try to use JSTL I get a strange exception and was hoping someone could help me resolve it.

My test.jsp looks like:
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt"  prefix="fmt" %>
<%
   request.setAttribute("today", new java.util.Date().toString());
%>
<html>
   <head>
      <title><c:out value="${today}" /></title>
   </head>
</html>
The exception I'm getting is:

According to TLD or attribute directive in tag file, attribute value does not accept any expressions
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146)
org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:955)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:710)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Validator.validate(Validator.java:1489)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:157)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

Any help with this would be greatly appreciated.
Thanks,
EB

Comments

843836
Ahh.. one more note, if I don't put a c:out around it and just ${today} it works fine.
794117
You're using the URI for JSTL1.0
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
With Tomcat 5 you should be using JSTL1.1 URI
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

Note the addition of the /jsp in the middle there?

Change your URI to this, and see if it works.
If not, you will have to get the updated version of JSTL from http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html

Explanation if you are interested:
JSP2.0 took over ownership of the Expression Language (EL).
In JSP1.2 JSTL expressions were interpreted by the JSTL interperter. As such they had to be strings, and the standard servlet engine had to leave them alone.
So for JSTL1.0, they declared all the attributes of the JSTL tags to NOT take a runtime expression.
Along comes JSP2.0, and suddenly ${ } gets interpreted as a runtime expression, where it wasn't before.
So if you use the old tld, it looks at the tag, sees it can't take a runtime expression, recognises ${ } as a runtime expression(where it wasn't before) and throws the error.

Solution: use the correct version of JSTL for your servlet container
JSTL1.0: Servlet2.3/JSP1.2 (eg Tomcat 4)
JSTL1.1: Servlet2.4/JSP2.0 (eg Tomcat 5)

Cheers,
evnafets

843836
Thanks very much, I changed the uri, that didn't work so I upgraded the jar and now it works perfectly.

Just to make sure.

Are all these correct then?

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
794117
Thanks very much, I changed the uri, that didn't work so I upgraded the jar and
now it works perfectly.
Good to hear.
Are all these correct then?
looks good to me.
The functions are new with JSTL1.1 - they're not available in JSTL1.0 - mores the pity as they are very useful.
843836
Thanks again, and yes I too have found them especially useful.

Cheers,
EB
1 - 5
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 25 2005
Added on Apr 27 2005
5 comments
169 views