If you create Java Web Projects, you will often receive:
javax.servlet.http.HttpServlet was not found on the Java Build Path.
This means that you miss a library with the specified class. The HttpServlet provides an abstract class to create an HTTP servlet for web applications.
1. Resolve the HttpServlet was not found Error
- The easiest (not recommended method) is adding the desired servlet jar into your class path manually.
- Copy the required jar file into your library folder in the web application.
- Right click the library in the project explorer and select Add to Build Path.
- If you use Maven you can add the following dependency to your pom.xml file; Be careful with the version and the target container. This is not recommended either, since you should use the servlet provided by your target container (e.g. Apache Tomcat).
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency>
- If you plan to use a servlet container like Apache Tomcat, continue reading.
2. Integrate Apache Tomcat into Eclipse
- Make sure you installed Apache Tomcat successfully. Check out this tutorial for detailed installation instructions.
- Now right click your Eclipse project and open the properties.
- Switch to Project Facets and select the Runtimes tab on the right hand side. Click New.
- Select the Apache Tomcat version you want to add (or another servlet runtime) and click Next.
- Add the Tomcat Installation Directory and click Finish. We use: E:\Developer\Tomcat\apache-tomcat-8.0.22.
- Check your created Apache Tomcat Runtime and click Apply.
- Please check your Java Version and adapt it. You need:
- Minimum JDK 1.7 for Tomcat 8
- Minimum JDK 1.6 for Tomcat 7
- Minimum JDK 1.5 for Tomcat 6
- Now the Tomcat dependencies including the javax.servlet.http.HttpServlet class are added to your Build Path.
- This should resolve the javax.servlet.http.HttpServlet Error.






Nice tutorial !