Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Wrox Announcements and Feedback > All Other Wrox Books
All Other Wrox Books Do you have a question about a Wrox book that isn't listed anywhere on p2p.wrox.com or where the forum is locked? Here's a forum to post questions about any other Wrox book so that other readers or one of the authors can help you with your questions. IF YOU ARE LOOKING FOR CODE DO NOT ASK "Where can I find the code for this book?" That question is answered here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the All Other Wrox Books section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 24th, 2003, 08:24 AM
Registered User
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to troutguy
Default JSP 2.0 book question...re: variables

New to JSP and following the above book exercises.

Even the simplest request for a value from a variable does not get "processed" by the server but is just displayed like so:

"code snippet"

4 * 4 is ${4 * 4}

Should display result of that in curly braces (16) but when processed by BEA WebLogic server as a web app it doesn't throw errors but just repeats value:


4 * 4 is ${4 * 4}

In several other exercises from the book the same thing is happening. Up to chapter two all jsp pages run and display OK but variables are not evaluated.

Steve Garrison
Wilmington, DE
  #2 (permalink)  
Old August 5th, 2003, 05:41 PM
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="http://java.sun.com/xml/ns/j2ee"

  <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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Book required for Professional JSP 2.0, 2.1 Abhijith Wrox Book Feedback 1 August 29th, 2007 11:30 PM
sharing variables throughtout the jsp application kanoorani JSP Basics 3 April 23rd, 2007 11:36 PM
Using global variables in jsp sumon_24_feb JSP Basics 1 March 23rd, 2007 07:45 AM
Page 91 of book: Global Variables. Nick Y BOOK: Ivor Horton's Beginning Visual C++ 2005 1 June 24th, 2006 10:48 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.