stephen.hartley (4) [Avatar] Offline
Second edition, Chapter 11, JSP Advanced Topics, page 192, final example on the page.

The text suggests that the JSP

<% (isUserLoogedIn) %>
Welcome, <%= userName %>!

will translate to the following servlet code:

if (isUserLoggedIn)
out.write("Welcome, ");

ie the value of userName is output regardless of the outcome of the 'if', but the "Welcome" is conditional.

However, I am running Tomcat ver 5.0.28 and the generated code is

if (isUserLoggedIn)
out.write("Welcome, ");
out.print( userName );

Hence the output of all of the text is not conditional. The line terminator in the JSP has been interpreted as printable output.

A quick look in the version 2.0 JSP spec does not give an example of this.

Could this be another error in the book? On the other hand, the accompanying text only says that omitting braces might cause undesired behaviour...