tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul FitzPatrick" <>
Subject RE: JSP quoting and escape conventions
Date Wed, 21 Feb 2001 20:39:55 GMT

Craig, I know you're the man, but it seems that the JSP Spec 1.1 says that
the JSP compiler should translate a %\> into %> and keep going looking for a
%> just to that his example would work.

"Section 2.4 Quoting and Escape Conventions" seems to me to say that in the
example he lists (here it is again :)
<% String foo = "testing %\>"; %>

should be allowable and that the JSP compiler should generate a line like :
String foo = "testing %>";

While I agree that
String foo = "testing %\>";
is invalid java code, it is the JSP compilers responsibility to convert the
JSP escape sequence.


-----Original Message-----
From: Craig R. McClanahan []
Sent: Wednesday, February 21, 2001 3:26 PM
Subject: Re: JSP quoting and escape conventions

William Au wrote:

> Yes, I see what you mean.  I guess it is a matter of what happen first.
> If the escape happens first, then the JSP
> <% String foo = "testing %\>"; %>
> would be translate to the following java code
> String foo = "testing %>";
> Then it would be valid java code.
> However, it seems to me in Tomcat, the translation happens first so the
> following
> invalid java code is generated:
> String foo = "testing %\>";

What is happening first is what *has* to happen first -- the JSP parser
sees the
"%\>" but recognizes (correctly) that this is not the end of the
scriptlet.  This
is exactly in accordance to the spec.

Therefore, all of the text between the "<%" and the "%>" is passed
through to the
language compiler for the scripting language (Java in this case),
by the JSP page compiler.  The uninterpreted code is not valid Java
syntax, and
therefore violates the JSP specification -- just the same as if you
forgot a
quote around the string literal, or omitted a required semicolon, or
made some
other error in Java syntax.

> Bill


To unsubscribe, e-mail:
For additional commands, email:

View raw message