Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysterious Eclipse JSP Validation Errors

Eclipse (Helios) occasionally marks valid looking JSP content as having errors. It seems like it often breaks when I use the <c:if> tag. For example, in a JSP with just this content:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <html> <body>  <c:if test="${1 == 1}"> something </c:if>  </body> </html> 

The following errors show in the "Problems" tab after I compile:

  • Incompatible operand types String and int line 1
  • javax.servlet.jsp.JspException cannot be resolved to a type line 1
  • javax.servlet.jsp.PageContext cannot be resolved to a type line 1

The code runs fine. Does the validation for JSPs have issues, am I missing something obvious, or does this indicate something isn't set up correctly.

like image 864
worpet Avatar asked Sep 24 '10 18:09

worpet


2 Answers

Well, I found how to solve this error. Add this to your Maven dependency(pom.xml):

<!-- dependency to fix JSPServletException -->     <dependency>         <groupId>org.apache.tomcat</groupId>         <artifactId>jsp-api</artifactId>         <version>6.0.32</version>         <scope>provided</scope>                    </dependency> 

Do comment if you find it useful, as much as it helped me.

like image 89
Mark Joseph Del Rosario Avatar answered Sep 21 '22 03:09

Mark Joseph Del Rosario


Based on the comments, I ended up turning off part of the JSP validation, which fixed this.

  1. Go to "Project->Properties->Validation".
  2. Click "Configure Workspace Settings...".
  3. Unselect options for JSP Syntax Validator (both manual and build).

I was hoping I was missing something and there was a way to fix this, but I have to concede that the JSP validation is junk.

like image 45
worpet Avatar answered Sep 20 '22 03:09

worpet