The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

823,476

Solution 1

Add a runtime first and select project properties. Then check the server name from the 'Runtimes' tab as shown in the image.

Select runtime from Project Facets as shown the in image

Solution 2

Project → PropertiesTarget RuntimesApache Tomcat worked for me. There is no Target Runtimes under Facets (I'm on Eclipse v4.2 (Juno)).

Solution 3

For an Ant project:

Make sure, you have servlet-api.jar in the lib folder.

For a Maven project:

Make sure, you have the dependency added in POM.xml.

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

Another way to do it is: Update the project facets to pick up the right server.

Check this box in this location:

Project → PropertiesTarget Runtimes → Apache Tomcat (any server)

Solution 4

Project → PropertiesTarget Runtimes → *Apache Tomcat worked for me. There is no Target Runtimes under Facets (I'm on Eclipse v4.4 (Luna)).

Solution 5

Adding the Tomcat server in the server runtime will do the job:

Project PropertiesTarget Runtimes → Select your Server from the list, "JBoss Runtime" → Finish

In case of Apache you can select Apache Runtime.

Enter image description here

Share:
823,476
disable1992
Author by

disable1992

Updated on January 13, 2022

Comments

  • disable1992
    disable1992 over 2 years

    I have a project created by Maven integration in Eclipse. All work fine, but in the work space in all JSP files have this:

    The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
    

    To the first string where place:

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    

    When I create a basic dynamic web project and JSP in - all is fine, no errors.