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

When we create a new java web project in eclipse or STS. It always shows the error message on JSP page as “javax.servlet.http.HttpServlet” was not found on the Java Build Path.

This is a servlet error, It means the project did not find any maven dependencies or jar to use servlet.

Now, below are the simple steps to solve the error: The superclass “javax.servlet.http.HttpServlet”, determined from the Dynamic Web Module facet version (2.3), was not found on the Java Build Path

In Maven Project

  • Open Pom.xml
  • Add the below servlet dependencies
  • Save the pom.xml
  • Update maven
<!-- https://mvnrepository.com/artifact/javax.servlet/servlet-api -->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>3.0-alpha-1</version>
    <scope>provided</scope>
</dependency>

In Java Dynamic Project

  • Download the servlet jar from the internet.
  • Import the servlet jar as an external library.
  • Refresh the application.