Ah,
Sorry. _That_ makes perfect sense.
It's what I get for not reading the original bug report in more
detail.
Although, I would expect in the following case...
When you do something like this:
% System.out.println(); // Hello % Some template text
then this gets translated into
System.out.println(); // Hello Some template text
To instead get:
System.out.println(); // Hello
out.print( Some template text );
Since Some template text is clearly outside of the % %, wouldln't
it be turned into generated output instead of code? Or am I being
pedantic and what you really meant was:
System.out.println(); // Hello out.print( Some template text );
or somesuch?
-Paul Speed
Craig R. McClanahan wrote:
On Mon, 22 Oct 2001, Paul Speed wrote:
Date: Mon, 22 Oct 2001 13:48:08 -0400
From: Paul Speed [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: DO NOT REPLY [Bug 4339] - Cannot use // comments in JSP
code
Only partially related to the bug, so I'm replying directly instead
of through bugzilla...
Does this mean that JSP uses a different Java language specification?
If so, where can I find this separate specification? Are there any
other big things like this that are incompatible with normal Java
syntax?
The JSP specification does not mandate the use of Java as a scripting
language -- you can use any language you want (as specified by the
language attribute of the %@ page % directive). However, many of the
features related to scripting are defined *only* for Java.
Note also that Jasper (the JSP page compiler in Tomcat) only supports Java
as a scripting language at the moment.
However, more germane to this bug report:
* Scriptlets are required to be well-formed according to the
rules of the scripting language in use (JSP 1.2, Section 2.11.2).
Thus, if you mistakenly leave off a semicolon at the end of a
Java statement in a scriptlet, the compilation error you get is
your fault. It's also your fault if the scope of your language
element extends outside the closing % delimiter in a manner
that causes invalid code to be created (such as mismatching }
brackets), or the case described in the following point.
* Scriptlets are translated into the generated code according
to the following rule (JSP 1.2, Section 6.4.2):
% scriptlet % --scriptlet
In other words, no newline is added after the % by the page
compiler (though the developer could certainly put a newline there).
When you do something like this:
% System.out.println(); // Hello % Some template text
then this gets translated into
System.out.println(); // Hello Some template text
and you get what you pay for. If you want to use // comments, do this
instead:
% System.out.println(); // Hello
% Some template text
and it will work fine.
Thanks,
-Paul Speed
Craig
[EMAIL PROTECTED] wrote:
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4339.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4339
Cannot use // comments in JSP code
[EMAIL PROTECTED] changed:
What|Removed |Added
Status|NEW |RESOLVED
Resolution||WONTFIX
--- Additional Comments From [EMAIL PROTECTED] 2001-10-22 10:11
---
You should not be using // comments. You have absolutely no control over the
Java code that is generated for your page, so it is your responsibility to use
well-formed constructs. In this particular case, that means to use /* */ style
comment markers so that you can explicitly close them. Even if we changed
Tomcat to do what you suggest, depending on this would not be portable and you'd
have massive problems as soon as you tried to switch to some other container
that didn't do it.
Using scriptlets at all can lead you into lots of other problems (such as
intermixing business logic and presentation logic that makes it very hard to
maintain and enhance your applications), but that is a whole separate
discussion.