Mysterious JSP Eclipse Checker Errors

Eclipse (Helios) sometimes marks the actual appearance of the JSP as having errors. It looks like it often breaks when I use the <c: if> tag. For example, in a JSP with only 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 appear on the Problems tab after compilation:

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

The code is working fine. Does confirmation for the JSP have a problem, I will skip something obvious or it indicates that something is not configured correctly.

+49
java eclipse validation jsp
Sep 24 '10 at 18:28
source share
16 answers

Based on the comments, I ended up disabling the JSP validation part that fixed it.

  1. Go to "Project-> Properties-> Validation."
  2. Click "Configure workspace settings ...".
  3. Deselect JSP Syntax Validator (both manual and assembly).

I was hoping something was missing and there was a way to fix it, but I have to admit that checking the JSP is unnecessary.

+37
Sep 24 '10 at 19:09
source share

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> 

Make a comment if you find this helpful, how much it helped me.

+47
Aug 02 '11 at 6:32
source share

I had the same problem, the problem is in the jsp-api library, you can add a dependency to your pom (as explained in other answers), or you can also add a target runtime and eclipse will automatically add this library to your class path:

 Project -> Properties -> Targeted Runtimes 

And select a server.

+21
Mar 12 2018-12-12T00:
source share

To fix it:
- javax.servlet.jsp. * need jsp-api.jar
- javax.servlet.http. * need servlet-api.jar

You need to add these libraries to the Java Build path in the project setup. These libraries can be found in the tomcat / lib directory (for Tomcat 6.0).

+5
May 31 '11 at 20:02
source share

This is an old question, but I thought I could mention it too in Juno on Mac OS X - especially most often after changing the external file and updating the project in Eclipse. It is emphasized in all odd places, even halfway through the words in the JSP comments.

Could (probably ?!) be related to error 376926 , which, apparently, was slightly corrected a week ago?

+3
Nov 16
source share

The solution for eclipse dependencies that should not be deployed adds the UserLibrary container and includes it in dependent projects.

  • Create a dir eg / home / user * / eclipse-deps / and copy jsp-api.jar from * / tomcat / lib dir
  • In Eclipse go to project properties -> build path and create a new "UserLibrary", for example. IdeDeps.
  • Include / home / user / eclipse-deps / in the IdeDeps library and include the user library in all jsp-api.jar-dependent projects (in classpath: <classpathentry kind = "con" path = "org.eclipse.jdt.USER_LIBRARY / IdeDeps "/>)

You can do this for all * .jars that should not be deployed, but eclipse is needed for verification.

+2
Aug 22 '11 at 10:16
source share

For Tomcat 7.0.x you will need the following in your pom

 <properties> <org.apache.tomcat.version>7.0.28</org.apache.tomcat.version> </properties> <dependencies> <dependency> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat-jsp-api</artifactId> <version>${org.apache.tomcat.version}</version> <scope>provided</scope> </dependency> </dependencies> 
+2
Jun 25
source share

Try to check the path to the project. It looks like you do not have a JSP library in your project (it is impossible to exclude "JspException" from here) or that your version of the library is not the same as the version of the JSP compiler.

The library is enabled by default on the application server on which you deploy your application, so the code works fine when deployed. However, if the internal Eclipse compiler is missing a library (or there is an incorrect version), the Eclipse editor shows you an error that does not exist on the application server.

+1
Sep 24 '10 at 18:35
source share

I had the same problem, and in the end I managed to start it by switching (from Maven) to version 2.3 of the servlet-api:

 <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.3</version> <scope>provided</scope> </dependency> 

Apparently 2.4 and above no longer have javax.servlet.jsp. You may be able to find this library in another package if you still want to use 2.4 or higher.

+1
Jul 13 '11 at 11:05
source share

You need to include jap-api.jar in your classpath.

+1
Nov 18 '11 at 7:30
source share

Much easier to use

select the project -> Properties -> Java Build Path -> Libraries Tab

Select add Libraries . From there, select Server Runtime . It will display all configured servers. From there, select the server runtime with which you linked your project.

This will lead to recovery and re-termination of projex, and all these ghost errors will be removed.

Hope this helps.

+1
Jun 26 '14 at 7:59
source share

Adding jsp-api.jar to your build class path will fix it. jsp-api.jar is under common\lib for tomcat 5.x

0
Jan 11 '12 at 17:55
source share

I also see the same problem during the transition to Maven (with m2e), get an error, for example, "javax.servlet.http cannot be resolved" and some Spring tags have an undefined warning. finally, I find this because the java version (v1.6) in my build configuration is not the same as in the facet configuration (v1.7). after changing v1.7 to v1.6 the problem disappears.

0
Feb 06 '12 at 13:00
source share

I had the same problem, but both jsp-api.jar and servlet-api.jar were already in the build path. Disabling JSP Syntax Validator also did not help.

Instead, I had to disable the JSP Content Validator , leaving the syntax validator enabled. I still underline the code in my JSP, but not the red cross indicating a compilation error, and that is the point :)

0
Jan 30 '14 at 10:51
source share

As many of you have mentioned, problems relate to the build path and missing libraries. I found a very simple fix for this problem. Here is the solution: In the Java Build Path section of eclipse, go to the Order and Export tab and make sure that the Apache Tomcat v7.0 library (or depending on the version of Tomcat you installed using eclipse). This fixes the problem instantly. No hassle with anything else. :-)

In this case, you also do not need to disable the check.

0
Jul 01 '15 at 8:55
source share

For me, when I printed the line manually, I got an error until I closed the tag, but the error did not disappear. I found a line of code that was similar, and I deleted the offensive code, copied and pasted the good code, and then made changes inside the tag as needed. No more mistakes !!! Not a perfect solution, but it worked for me.

0
Sep 06 '16 at 19:43
source share



All Articles