View Single Post
  #2 (permalink)  
Old August 5th, 2003, 05:41 PM
pdenhaan pdenhaan is offline
Authorized User
Join Date: Aug 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts

Yes. Of all the problems with the book this is one of the most subtle, and annoying.

The problem is the deployment descriptor (WEB-INF/web.xml file). For backwards compatibility, if you use an old-style (Servlet 2.3/ JSP 1.2) deployment descriptor, the JSP container must disable all the fancy new JSP 2.0 features which might break existing software. This includes the expression language (EL).

As the specification has it: "Each JSP page has a default EL evaluation mode that may be true or false. The default mode for JSP pages in a Web Application delivered using a web.xml using the Servlet 2.3 format is false; this provides for backward compatibility.
The default mode for JSP pages in a Web Application delivered using a web.xml using the Servlet 2.4 format is true; this provides automatically the default that most applications want.
The default can be changed by setting the value of the elEvaluation property of the page, either through a page directive, or through the JSP configuration information for the web application using the el-enabled element."

Now the problem with the early chapters in the BJSP2 book is that they don't use an explicit deployment descriptor at all, let alone a Servlet 2.4/JSP 2.0 descriptor. Tomcat then goes into "compatibility mode" and disables the expression language. The easiest way to address this would be to include the following snippet at the top of your JSP pages:

<%@page isELEnabled="true"%>

This should enable EL evaluation in the page. I have not tried this with the current version of Tomcat though. Alternatively, you could use a proper deployment descriptor as discussed (much) later in the book, along the lines of

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns=""

  <display-name>Hello World!</display-name>

Of course this oversight is unforgiveable; how come nobody caught this? Simple. At the time when the book was written, the only JSP 2.0 software was alpha quality, early access software which did not implement this JSP versioning feature at all, and all the code in the book worked happily for us. None of the reviewers picked up on it either.

Hope this helps

 - Peter