Expression Language in JSP not working [duplicate]

I’m quoting from an answer I provided before to the problem of EL not working:

With other words, the EL expression doesn’t get evaluated? 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 is configured with isELIgnored=true.
  4. The web.xml is configured with <el-ignored>true</el-ignored> in <jsp-config>.

In your particular case, EL works in taglibs, but not in template text, so I suspect it’s caused by point 2. Ensure that your web.xml is declared as at least Servlet 2.4. As Tomcat 6.0 supports Servlet 2.5, I would recommend to declare your web.xml as Servlet 2.5:

<web-app 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="Your_WebApp_ID"
    version="2.5">

    <!-- Here you go. -->

</web-app>

Another rare cause I’ve seen on this is that there’s a collision with EL JAR’s in the classpath. Ensure that you have not copied any appserver-specific JAR files into your webapp’s WEB-INF/lib or, more worse, the JRE/lib.

As you’re already using Eclipse and Tomcat, I would review the development steps you used for this all. Ensure that you’re using “Eclipse for Java EE developers” and that you’ve integrated the Tomcat instance in Eclipse’s Servers view and that you’ve created a Dynamic Web Project set to “Servlet 2.5” which makes use of the Tomcat instance. This way everything should go automagically (Eclipse will take appserver’s libraries in the build path itself and autogenerate a Servlet 2.5 compliant web.xml).

Update: as per your update: those com.servlet.El servlets look suspicious. What exactly do they do? Parsing EL? Remove them and retry.

Leave a Comment