Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 136795 - EL Syntax Error accessing collection via string
Summary: EL Syntax Error accessing collection via string
Status: VERIFIED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: jst.jsp (show other bugs)
Version: 1.5   Edit
Hardware: PC Windows XP
: P3 normal with 12 votes (vote)
Target Milestone: 3.0.3   Edit
Assignee: Nick Sandonato CLA
QA Contact:
URL:
Whiteboard: PMC_approved
Keywords:
: 112527 149392 156034 206704 238752 239913 252336 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-04-14 01:40 EDT by Brent D. Metz CLA
Modified: 2009-06-15 10:56 EDT (History)
19 users (show)

See Also:
david_williams: pmc_approved+
thatnitind: pmc_approved? (raghunathan.srinivasan)
thatnitind: pmc_approved? (naci.dai)
thatnitind: pmc_approved? (deboer)
thatnitind: pmc_approved? (neil.hauge)
thatnitind: pmc_approved? (kaloyan)
thatnitind: review+


Attachments
patch (3.27 KB, patch)
2008-10-20 16:35 EDT, Nick Sandonato CLA
no flags Details | Diff
patch with a max number of regions in the loop (3.79 KB, patch)
2008-10-29 12:00 EDT, Nick Sandonato CLA
no flags Details | Diff
patch for more than 1 EL region in a container (3.77 KB, patch)
2008-10-29 14:14 EDT, Nick Sandonato CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent D. Metz CLA 2006-04-14 01:40:16 EDT
on WTP 3.2M5 The following in my JSP is being marked as an EL Syntax Error:

${header["Accept"]}

The code executes fine. Other uses of the ["foo"] notation show up as syntax errors as well. If I change it to ${header[0]} it doesn't complain.
Comment 1 Eric Quilantang CLA 2006-04-28 11:42:42 EDT
I'm also seeing a similar error with this line
${fn:join(row.errorProofing, ',')}
I get the highlights on the single quotes.
Comment 2 Eric Quilantang CLA 2006-04-28 11:48:34 EDT
I see a similar problem in this line
${fn:join(row.errorProofing, ',')}
warnings highlight on the single quote.

using eclipse 3.2RC1, webtools 1.5
Comment 3 Brent D. Metz CLA 2006-05-04 16:11:30 EDT
May be related:

${(1 < 0) ? "YES" : "NO"} produces an EL Syntax Error as well. I got this example out of Core Servlets page 494 so I presume it's valid. Sometimes 1 and 0 need to be complex objects (ie request.header) to trigger the yellow squigglies but they stick.
Comment 4 Nobody - feel free to take it CLA 2006-06-19 15:58:58 EDT
Still seeing this in RC5. Perhaps related, but in the last month references to param collection elements seem to flag as errors incorrectly as well, ie:

<option ${(param.foo eq "0")?"selected":""} value="0">Foo</option>

Since the string collection accessor is also failing there seems to be no workaround to the problem.
Comment 5 Bob Tiernay CLA 2006-11-30 08:50:52 EST
Any idea on when this might be fixed?  I recently stopped using the BEA Workshop JSP plugin (which does validate correctly) and now noticed that my project has several hundreds of errors. This makes it quite difficult to find "real" warnings. 

Suggestion:
Add "Ignore warning" option to the context menu of the Problems view.
Comment 6 Nobody - feel free to take it CLA 2007-02-20 16:40:14 EST
Adding my post-IBM email..this is still a big annoyance to me as most of my JSPs end up showing false errors.
Comment 7 Chandra Sekar S CLA 2007-08-31 10:09:16 EDT
When I write the following code in a JSP page in Eclipse, it gives a warning, "EL Syntax Error".

${param['user']}

It also says that the word 'param' is not correctly spelled and underlines it with a yellow squiggly. The two "EL Systax Error" messages are show at the two ']'. I'm using Eclipse Europa for JEE developers.  I receive the expected output when the page is loaded on the browser.

It is extremely intimidating when a 100% correct JSP page shows several wrong warning messages.
Comment 8 Kai Weber CLA 2008-06-30 04:26:02 EDT
This bug is more than two years old and still present in Eclipse 3.4. Any progress regarding this annoying behaviour?

Regards,
Comment 9 Lee Kon Keong CLA 2008-07-22 12:06:13 EDT
I have a simple JSP, see below.

    [<a href="<%= request.getContextPath()%>/${backToRegister != null ? 'register' : 'enquire'}/home.do"
        >${backToRegister != null ? 'Go to Registration' : 'Back to main'}</a>]

It is giving me an error "EL Syntax Error".

Description	Resource	Path	Location	Type
EL Syntax Error 	failEnquire.jsp	xxx	line 0	JSP Problem

It is making a red squiggle mark before the second ":".

${backToRegister != null ? 'Go to Registration'<red_mark_here>: 'Back to main'}




Comment 10 Neil Hart CLA 2008-08-06 13:49:51 EDT
Just wanted to +1 this issue.  I've got:

User Login from ${header["host"]}

with red markings under the "


Comment 11 Nick Sandonato CLA 2008-10-20 16:35:45 EDT
Created attachment 115620 [details]
patch

Adding a patch to fix the EL validator so that it considers all of the content of the EL container and not just regions that are of the type JSP_EL_CONTENT.
Comment 12 Nick Sandonato CLA 2008-10-20 16:37:27 EDT
Nitin, could you please take a look at this patch before I release it?
Comment 13 Nick Sandonato CLA 2008-10-28 14:00:52 EDT
* Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such. 
      Without these changes, the JSP EL validator will incorrectly identify problems in EL regions that contain some kind of EL syntax and a string literal.
      
* Is there a work-around? If so, why do you believe the work-around is insufficient? 
      Yes, the work-around is to ignore EL Syntax problems in the JSP Validation preferences. The drawback to this is that real EL syntax problems will be ignored as well.
      
* How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added? 
      No JUnits, but the fix has been tested manually using the numerous failing EL regions posted in the comments of the bug.

* Give a brief technical overview. Who has reviewed this fix? 
      Before, the JSPELValidator would skip quoted regions in JSP EL content, thus the validated EL content would be incomplete and syntax validation would fail. Now, the validator looks at the content of the EL region as a whole instead of splitting it up into regions. Nitin has reviewed this fix.
      
* What is the risk associated with this fix? 
      Minimal. The change only affects the EL validator and the text that it validates.
Comment 14 Nick Sandonato CLA 2008-10-28 16:23:53 EDT
*** Bug 252336 has been marked as a duplicate of this bug. ***
Comment 15 Nitin Dahyabhai CLA 2008-10-29 09:43:28 EDT
Looks good.

For the technical information, we currently break up any EL regions into different pieces depending on the presence of quotes.  Without this patch, only the segment before the first quote would be sent to the EL parser.  The patch changing this to properly use the entire EL content.
Comment 16 David Williams CLA 2008-10-29 10:01:16 EDT
I think this is great and a needed fix, but can you comment on one (potential) issue. I'm wondering about "runaway code" in loops such as that below (from your patch) ... what if there is no 'close' region (yet) ... seems it might slow down typing in a large file, until the user types '}'. I don't recall (but Nitin might :) it seems like in some cases we put in some huge maximum regions we'd check, like 500? 1000? That at least prevents an apparent hang if someone has a megabyte jsp file, or similar. 


+ /* Find the EL closing region, otherwise the last region will be used to calculate the EL content text */
+ while (elRegions != null && elRegions.hasNext()) {
+ 	elRegion = (ITextRegion) elRegions.next();
+ 	if (elRegion.getType() == DOMJSPRegionContexts.JSP_EL_CLOSE)
+       	break;
+}
Comment 17 Nitin Dahyabhai CLA 2008-10-29 11:40:15 EDT
(In reply to comment #16)
> I think this is great and a needed fix, but can you comment on one (potential)
> issue. I'm wondering about "runaway code" in loops such as that below (from
> your patch) ... what if there is no 'close' region (yet) ... seems it might
> slow down typing in a large file, until the user types '}'. I don't recall (but
> Nitin might :) it seems like in some cases we put in some huge maximum regions
> we'd check, like 500? 1000? That at least prevents an apparent hang if someone
> has a megabyte jsp file, or similar. 
> 
> 
> + /* Find the EL closing region, otherwise the last region will be used to
> calculate the EL content text */
> + while (elRegions != null && elRegions.hasNext()) {
> +       elRegion = (ITextRegion) elRegions.next();
> +       if (elRegion.getType() == DOMJSPRegionContexts.JSP_EL_CLOSE)
> +               break;
> +}

Adding limits sounds reasonable, but just to assuage any concerns, the JSP parser only divides the EL into quoted and non-quoted segments.  It's not a full syntactic breakdown, so the common case would be a somewhat small number.

Nick, please attach an updated patch with a limit of 1000 or so for the while loop.
Comment 18 Nick Sandonato CLA 2008-10-29 12:00:06 EDT
Created attachment 116434 [details]
patch with a max number of regions in the loop

Added a check of 1000 regions before exiting the loop.
Comment 19 Nick Sandonato CLA 2008-10-29 14:14:00 EDT
Created attachment 116451 [details]
patch for more than 1 EL region in a container

Removed the break from the conditional that checks EL content because there may be more than one EL expression in the container. For example, <a href="${fn:trim('http://  ')}${fn:trim('www.eclipse.org') }">Eclipse</a>
Comment 20 David Williams CLA 2008-10-30 12:47:48 EDT
yes, I'm fine with this. 
Comment 21 Nick Sandonato CLA 2008-10-30 14:24:12 EDT
Released to 3_0_Maintenance.
Comment 22 Nick Sandonato CLA 2008-11-03 11:21:06 EST
In RC2.
Comment 23 Nick Sandonato CLA 2008-11-13 11:36:43 EST
Released to HEAD.
Comment 24 Nick Sandonato CLA 2008-11-14 13:55:29 EST
Verified in wtp-R-3.0.3-20081113203138.
Comment 25 Nick Sandonato CLA 2008-12-12 10:32:15 EST
*** Bug 239913 has been marked as a duplicate of this bug. ***
Comment 26 Ian Tewksbury CLA 2009-06-15 10:26:40 EDT
*** Bug 156034 has been marked as a duplicate of this bug. ***
Comment 27 Ian Tewksbury CLA 2009-06-15 10:31:38 EDT
*** Bug 238752 has been marked as a duplicate of this bug. ***
Comment 28 Ian Tewksbury CLA 2009-06-15 10:36:34 EDT
*** Bug 149392 has been marked as a duplicate of this bug. ***
Comment 29 Ian Tewksbury CLA 2009-06-15 10:39:04 EDT
*** Bug 206704 has been marked as a duplicate of this bug. ***
Comment 30 Ian Tewksbury CLA 2009-06-15 10:56:14 EDT
*** Bug 112527 has been marked as a duplicate of this bug. ***