JSP EL (Expression Language) causing problems in Eclipse
Asked Answered
A

1

7

My system: Ubuntu 9.10. Eclipse 3.5.1 with Java EE 1.2.1 (manual install - NOT from synaptic). Web Developer Tools 3.1.1

I've recently adopted someone else's code (a Dynamic Web Project), and run into lots of errors, warnings and incorrect syntax highlighting in Eclipse. I've narrowed it down to these 4 lines of code (create a new Dynamic Web Project, and then a new JSP page, and put this in the body):

${(1<2)? "" : "no"}
<%for (int i = 0; i < 5; i++) {%>
<div>${5}</div>
<%}%>

Errors / Warnings / Incorrect syntax highlighting

line1: yellow warning line under '<': Invalid character used in text string (${(1<2)? "yes" : "no"}).

line2: red error line under 'f': Multiple annotations found at this line: 1) Syntax error, insert "Finally" to complete TryStatement. 2) Syntax error, insert "}" to complete ClassBody

line2: red error line under ')': Syntax error on token ")", try expected after this token

line3: yellow warning line under 'div': No end tag (/div).

line3: yellow warning line under '<' of closing div: Multiple annotations found at this line: 1) Invalid character used in text string (${5} <%}%>). 2) Invalid character used in text string (${5} <%}%>).

line3: '/div' is black and purple (for scriptlet code?) instead of green for HTML code

line4: The opening and closing scriplet tags '<%' and '%>' are black instead of orange

The page works as expected in a browser: you get '5' five times. If you change the empty quotes on line 1 to "yes" then save, close the file in the editor, r click it in the project explorer > validate, then re-open it: all errors / warnings / incorrect syntax highlighting disappear, except the first one (invalid character). This is incredibly irritating. Any thoughts would be greatly appreciated.

Amundson answered 24/11, 2009 at 15:20 Comment(2)
Yes, the Eclipse JSTL editor support is crap.Foreclosure
Can anybody else confirm the same behaviour (if you create a new Dynamic Web Project, and then a new JSP page, and put the above quoted code in the html body)? You may need to save, close, validate and re-open to see the errors/warnings. Thanks. P.s. this is another (probably related) problem; why is it that new errors/warnings only appear if you save, close, validate and re-open the file? It makes it kind of un-usable...Amundson
V
14

Eclipse WTP is great, but exactly this problem is an epic fail in Eclipse WTP for me as well. They seem to be working on that, but until then I just disable/set-to-ignore all of the validation related to this stuff in the workspace preferences through Web > JSP Files > Validation > scroll list to very bottom and set all EL validation settings to Ignore. Also in the main Validation preference uncheck all checkboxes related to JSP. This however doesn't seem to remove every warning/error, but it at least minimizes the annoyance.

IntelliJ IDEA handles JSP/EL validation much better.

To me, the symptoms make me think that WTP is using regexp instead of a stackbased parser to validate HTML/JSP/EL. This is a big no-no in case of structured markup.

Vierno answered 24/11, 2009 at 15:38 Comment(3)
Sorry I don't know how to send private message. Please, see following answer comments. As I understand it points in your blog. https://mcmap.net/q/358153/-how-do-i-return-a-video-with-spring-mvc-so-that-it-can-be-navigated-using-the-html5-lt-video-gt-tagPartizan
10 years later Eclipse still seems to not be able to handle JSTL / EL. If I take a perfectly fine application according to Netbeans and open in the latest Eclipse I'm advised by the Eclipse Validator that a ton of my syntax is wrong. I've tried disabling global validation and also updating my web.xml to 3.1 from 3.0, but still no better. Now I remember why I choose Netbeans a decade ago.Defenestration
@Ryan: These days, I'm fond of the JBoss Tools plugin on this. Not sure if it also works on JSP files, I'm only using Facelets files.Vierno

© 2022 - 2024 — McMap. All rights reserved.