开发者

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

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.interfa开发者_Go百科cesList}" 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...


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>


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


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜