Skip Links

Blog

Posts tagged with "expression language".

Troubleshooting Expression Language support in Java web applications

Mark

Mark

29 Oct 2010 21:24

Sometimes it can be confusing as to why your expression-language expressions are not being evaluated in your JSP.

The confusion is almost always because of misunderstanding of when EL expressions will be ignored by default and when they will be evaluated.

EL evaluation is controlled in four places:

  1. The servlet version your web server supports
  2. The servlet version specified in your web.xml file
  3. The el-ignored element in your web.xml file
  4. The isELignored page directive in your JSP
Servlet version

Your container must support the version you specify in your web.xml file. Don’t try and go higher if your web server doesn’t support it, it may not drop down cleanly to the highest version it does support.

Consult the documentation for your web server, for Tomcat:

  • 5.5 – servlet 2.4
  • 6.X – servlet 2.5
  • 7.0 – servlet 3.0
Servlet version in web.xml

Include the appropriate version and namespaces in your web-app element.

<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/j2ee/web-app_2_4.xsd"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
	version="2.4">

el-ignored element

In your web.xml file, set the el-ignored element. This setting will apply right across your web-app.

<jsp-property-group>
  ...
  <el-ignored>false</el-ignored>
  ...
</jsp-property-group>

isELignored page directive

Finally, you can set whether your expressions will be evaluated in your JSP. Set it to false and expressions are evaluated

<%@ page isELIgnored="true" %>

Tagged in: expression language, JSP, EL