Sunday, January 15, 2012

EL not evaluated in JSP

I've spent almost an hour do discover why Expression Language entries like:

${test}

are not evaluated on JSP pages.

The thing was version in web.xml file.
By default my eclipse generated

<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>

...

Changing to

<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/web-app_2_4.xsd"
version="2.4">

...

made it work.

Make sure you have also in your server classpath 2 jar files:

jstl.jar - JSTL implementation classes
standard.jar - Standard Taglib JSTL implementation classes

More reference in this  thread.