EL expressions won't executed in Tomcat 5.5, but working in tomcat 6.0.20
Asked Answered
R

3

16

I am developing my application using spring-web-mvc...

Now at my Controller it returns like this :

  public class InterfacesManageController implements Controller {
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception  {

    Map<String, Object> myModel = new HashMap<String, Object>();

    myModel.put("interfacesList", this.interfacesSecurityProcessor.findByAll(0, null, null, null));

    return new ModelAndView("common", "model", myModel);
}

Now, my JSP contains following code :

<c:forEach items="${model.interfacesList}" var="prod">
     <c:out value="${prod.id}"/> <c:out value="${prod.name}"/><br><br>
</c:forEach>

Now when i am executing this to Windows platform where i have tomcat 6.0.20, ognl 2.6.11 it's giving me exact output which i want like :

117 eth1

118 eth1

119 eth0

But, when i am deploying war file in unix (cent os) platform, where i have tomcat 5.5, the ognl expression doesn't get executed and giving me output like :

${prod.id} ${prod.name}

Can anybody have solution, what should be the problem with ognl expression version and tomcat version ?

Thanks in advance...

Revue answered 12/11, 2009 at 11:16 Comment(0)
P
36

But, when I am deploying war file in Unix (CentOS) platform, where I have Tomcat 5.5, the EL expression doesn't get executed and giving me output like:

${prod.id} ${prod.name}

In other words, the EL expression doesn't get evaluated at all and is showing as plain text? That can have one or more of the following causes:

  1. Application server in question doesn't support JSP 2.0.
  2. The web.xml is not declared as Servlet 2.4 or higher.
  3. The <%@page %> of JSP is configured with isELIgnored=true.
  4. The web.xml is configured with <el-ignored>true</el-ignored> in <jsp-config>.

Tomcat 5.5 is Servlet 2.4/JSP 2.0, so #1 can be scratched. You didn't change anything in webapp before deploying I assume, so #3 and #4 can likely be scratched. Now left #2. Maybe you declared it as Servlet 2.5 for Tomcat 6.0 while the Tomcat 5.5 only understands up to with Servlet 2.4. This way everything will become a mess as Tomcat would then fallback to least compatibility modus. You need to redeclare web.xml as Servlet 2.4 so that it will work in both Tomcat 5.5 and 6.0. The declaration should look like:

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

    <!-- Here you go. -->

</web-app>
Paraph answered 12/11, 2009 at 11:48 Comment(2)
Got the solution BalusC.... Thanks a lot for your answers... Actually i was declaring Servlet 2.5 for my tomcat 6.0.20. As you told me, i have changed it to Servlet 2.4, everything is working fine...Revue
@Paraph Thank you so much. I spent lot of time to recover from JasperException. Finally I got this. I had solve my problem with your sample web.xml declaration. And adding jstl.jar and standard.jar. +1 for web.xml.Sippet
P
1

Are you sure that you have included JSTL library either on Tomcat or your Web Application's lib folder?

These links will help you:

How to set up Tomcat to work with JSTL

How to reference and use jstl in your web application

Pickens answered 12/11, 2009 at 11:30 Comment(3)
If JSTL wasn't installed you should have seen nothing in the visual output and everything (unparsed/unevaluated) in the HTML source.Paraph
I do have JSTL in my classpath.. That's why i am getting output in windows with tomcat 6.0.20.. I am sure...Revue
It would not have worked if JSTL was in classpath of Tomcat 6.0, but not in the classpath of Tomcat 5.5. You apparently have it, or it is in the classpath of the webapp, then it would have worked on all environments. But OK, as said this is not the root cause of the problem here.Paraph
D
1

Thanks to BalusC for his excellent answer. I had the exact same problem that he diagnosed above, and his solution got me part of the way there. However, I also had to make sure that various JSP and JSTL dependencies of my application were all compatible. In particular, I was referencing JSTL 1.2 and this problem didn't go away until I changed that dependency to JSTL 1.1.2 (at which point I had to also add an explicit dependency on taglibs.standard:1.1.2).

The following blog post provides a lot more information on compatibility between different versions: http://www.mularien.com/blog/2008/04/24/how-to-reference-and-use-jstl-in-your-web-application/

Desolate answered 3/9, 2013 at 16:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.