Tuesday 8 March 2011

Why doesn't EL work in my JSPs ... answered

So, you're working away on a relatively legacy application ... and you decide that as you're running the application in a new-ish (think Tomcat 6 level) servlet container, you might as well actually use some JSTL.

Makes sense right ? Course it does !

So you go and add it, all good. Then you pre-compile your jsps and deploy, and your met with:

${user.name}

in your jsp ... Hmmmm what could be the matter ?!?!? (actually it was more WTF, but hey)

Well, it turns out that, the DTD referenced in the application web.xml was out of date (was referencing 2.3), and hence none of the EL functionality is enabled by default !!

The solution is to either update your web.xml to reflect your container, OR if you can't follow the directions in the link below to add EL support.

Frankly, the mapping of servlet containers to JSP and JSTL versions, and associated jars, is not trivial. Fortunately, someone else has done a fantastic job of pulling all the information together:

http://tech.zhenhua.info/2009/01/version-matching-of-jsp-jstl-and.html

Thank you Gerald !