How to resolve the error - The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

13

I'm using Eclipse Mars.1 for Web development, I got this error by including a file JSP , The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path .

I also have Tomcat 8 running on the PC.

    
asked by anonymous 27.10.2015 / 23:01

3 answers

14

As with the database, Eclipse does not recognize the Apache Tomcat service just because it is present on the system, a plugin for < strong> Eclipse .

  • In Eclipse go to Window > Preferences > Server Runtime Environments

  • Nowselectyourprojectandrightclick>PropertiesProjectFacets>Runtimes>/strong>selectApacheTomcat8,applyandanOKex:

The error should have gone away, trying to fix the problem, before I installed Eclipse a Tomcat plugin and Jboss Apache Tomcat Integration software , but I do not know how far these are needed.

    
27.10.2015 / 23:01
8

The solution I found was a bit different, and I'll leave it here as just adding the server and changing Project Facets did not help me:

  • In the pom.xml file, in the dependencies field, add:
  • <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>
    
  • The change must be recognized immediately; otherwise, right-click on your project, Maven option - > Update Project (or just Alt + F5).
  • 07.06.2016 / 04:27
    1

    Good evening personal

    The solution to add the dependency in Maven also solves it. Just to help, it can be solved the first way it was suggested by adding the Target Runtime in Project Facets. It turns out that after doing this, you must also configure the project to use the libraries of the server in question. To do this, go to the Build Path settings, on the "Libraries" tab, click the "Add Library" button, select "Server Runtime" and then the Server you used, in my case "Tomcat 7.0" Then just apply and that's it.

        
    07.05.2018 / 02:24