RSS Feed Subscribe to RSS Feed

 

JSP EL statements not being evaluated

On several occasions I have had problems with EL (Expression Language) statements not being evaluated.
As an example, you add a statement to a JSP like
$(2+2), expecting the JSP to simply display 4, when it in fact displays the raw statement, i.e. $(2+2).

After digging around the web, I found a number of points to check…

  • Check you application server supports JSP 2.0 or above (Tomcat 5.0 and higher does)
  • Check your web.xml descriptor file is using at least version 2.4 of the Servlet deployment descriptor (I have been using 2.5). If it is using Servlet 2.3 spec or earlier, EL will be disabled by default.
  • Even if you are using version 2.5 of the Servlet deployment descriptor, make sure that the schemaLocation is correct. For example, I copied this from somewhere on the web and it failed to work:
    
    
    
    

    I then found this version, which does work correctly. Note the subtle difference in the schema location of j2ee vs javaee.

    
    
               
    

    I found the above here at Oracle.

  • As a last resort, you can use <%@ page isELIgnored="false" %> in your JSP, but having to do this is usually a sign that something else may be wrong (as described above).

Related posts: