The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
Solution 1
Add a runtime first and select project properties. Then check the server name from the 'Runtimes' tab as shown in the image.
Solution 2
Project → Properties → Target Runtimes → Apache 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 → Properties → Target Runtimes → Apache Tomcat (any server)
Solution 4
Project → Properties → Target 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 Properties → Target Runtimes → Select your Server from the list, "JBoss Runtime" → Finish
In case of Apache you can select Apache Runtime.
disable1992
Updated on January 13, 2022Comments
-
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.