July 8, 2015

Error [solved] The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path

Problem : The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path.
Faced this error while using maven integration with eclipse. 
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
First found this error on the start of JSP page with one red mark over above piece of code.

Solution : Below, I have written three solution for this problem. I guess, one will work for you.

Method 1: Add Maven dependency(pom.xml)
Include servlet-api-3.1.jar in your dependencies.
 <dependency>  
  <groupId>javax.servlet</groupId>  
  <artifactId>javax.servlet-api</artifactId>  
  <version>3.1.0</version>  
  <scope>provided</scope>  
 </dependency>  

Method 2: Add a Runtimes
Properties > Project Facets > Runtimes > Check Server name > Apply > OK (As shown in Image)

Method 3: Select a Runtime to add to the classpath
Java Build Path > Libraries > Add Library > Server Runtime > Next (As shown in Image)
then select a Runtime(Apache Tomcat Server) > Finish > OK (As shown in Image)

0 comments:

Disclaimer

We shall not be liable for the improper or incomplete transmission of the information contained in this communication nor for any delay in its response or damage to your system. We do not guarantee that the integrity or security of this communication has been maintained or that this communication is free of viruses, interceptions or interferences. Anyone communicating with us by email accepts the risks involved and their consequences. We accept no liability for any damage caused by any virus transmitted by this site.