Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

jsp

tomcat

el

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

like image 455
Nirmal Avatar asked Nov 12 '09 11:11

Nirmal


1 Answers

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>
like image 192
BalusC Avatar answered Sep 22 '22 14:09

BalusC