Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Add alternative solution to fixing the HttpServlet not found

...

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

Eclipse might show you an error marker on your project, claiming that "The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path". You can fix this by opening the properties of your project (right click on your project > Properties). Then click on "Project Facets" and from the facet list select "Dynamic Web Module." On the right, click on "Runtimes" and select "Apache Tomcat v8.0".

By adding target runtime to the project, http-servlet will be available to the project class-path.

Alternatively, you can fix this by adding javax.servlet.jsp-api to the pom and mark the dependency as provided

Code Block
languagexml
titlepom.xml
<dependency>
    <groupId>javax.servlet.jsp</groupId>
    <artifactId>javax.servlet.jsp-api</artifactId>
    <version>2.2.1</version>
    <scope>provided</scope>
</dependency>


Let Spring take over

Now, you are all setup to start with Spring. First, you need to tell Tomcat that you want Spring to handle incoming requests. You do this by specifying which servlet Tomcat should use as 'entry point' into your application. Open the file web.xml located in src > main > webapp > WEB-INF. Add the following code inside the 'web-app' tag after the 'display-name' section:

...