Bug 238385 - [validation] JSP parser : <%= true // comment %> is validated as a correct expression
Summary: [validation] JSP parser : <%= true // comment %> is validated as a correct ex...
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: jst.jsp (show other bugs)
Version: 2.0.2   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.2   Edit
Assignee: Ian Tewksbury CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard: qplan
Keywords: plan
Depends on: 289258
Blocks:
  Show dependency tree
 
Reported: 2008-06-25 04:10 EDT by Mauro Molinari CLA
Modified: 2010-02-25 14:10 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mauro Molinari CLA 2008-06-25 04:10:43 EDT
Build ID: M20080221-1800

Steps To Reproduce:
1. create a Dynamic Web Project
2. create a new JSP
3. try to write such a JSP expression:

<%= true // comment %>

The parser doesn't give any error and also syntax coloring suggests that this is a correct expression. However, if you try to run such a JSP in Tomcat, a JSP compilation error is given ("syntax error").
Comment 1 Nitin Dahyabhai CLA 2008-07-07 21:00:24 EDT
Hmm, the translation we use adds line breaks before and after, which means for us that there isn't an error there.  I'm not sure whether the spec says to do it one way or the other.

out.print(""+
 true // comment 
);
Comment 2 Mauro Molinari CLA 2008-07-08 03:23:46 EDT
(In reply to comment #1)
> Hmm, the translation we use adds line breaks before and after, which means for
> us that there isn't an error there.  I'm not sure whether the spec says to do
> it one way or the other.
> 
> out.print(""+
>  true // comment 
> );

Reading the JSP 2.0 specs, what I could find is that the syntax for an expression is:
<%= expression %>
Then:
"An expression element in a JSP page is a scripting language expression that is
evaluated and the result is coerced to a String. The result is subsequently emitted into the current out JspWriter object.
If the result of the expression cannot be coerced to a String the following must
happen: If the problem is detected at translation time, a translation time error shall occur. If the coercion cannot be detected during translation, a ClassCastException shall be raised at request time."

So, what I would expect is that the whole contents of <%= ... %> can be evaluated to a String. "true // comment" isn't actually an expression (it's made of an expression and a comment) and it can't be translated into String as a whole.

This is my interpretation...

Mauro.
Comment 3 Nitin Dahyabhai CLA 2008-07-23 19:49:45 EDT
And it's a good one.  The line breaks need to go.
Comment 4 Ian Tewksbury CLA 2009-09-28 14:06:25 EDT
(In reply to comment #3)
> And it's a good one.  The line breaks need to go.

This will be taken care of by Bug 289258.
Comment 5 Mauro Molinari CLA 2009-09-29 03:22:09 EDT
Nice to read that you are working on the JSP editing tools of WTP! Good work! As I already said in the newsgroups, WTP really needs a boost on that!
Comment 6 Nick Sandonato CLA 2009-11-16 16:04:12 EST
(In reply to comment #4)
> (In reply to comment #3)
> > And it's a good one.  The line breaks need to go.
> 
> This will be taken care of by Bug 289258.

Hey Ian, can this be resolved now?
Comment 7 Nick Sandonato CLA 2010-02-25 14:10:18 EST
Fixed by Bug 289258.