Java and Technology weblog
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:
<?xml version="1.0" encoding="ISO-8859-1"?> <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_5.xsd" Version="2.5">
I then found this version, which does work correctly. Note the subtle difference in the schema location of j2ee vs javaee.
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
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).
- XML Schema for the Servlet 2.5 deployment descriptor[java.sun.com]
- Java EE 5 – Unified Expression Language[oracle.com]
- JSP, JSTL, Servlet and Tomcat version matching[coderanch.com]
- Stack Overflow related problem postings:
- EL in a JSP stopped evaluating[stackoverflow.com]
- JSP: EL expression is not evaluated[stackoverflow.com]