Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (10.2k points)

I have a project created by Maven integration in Eclipse. All work fine, but in the workspace 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.

2 Answers

0 votes
by (46k points)

To solve this error you need to add a runtime at the beginning and select project properties. Then verify the server name from the 'Runtimes' tab as displayed in the image.Select runtime from Project Facets as shown the in image

0 votes
by (37.3k points)

The reason why you are getting the error regarding the JSP file cannot access ‘HttpServlet’ because ‘javax.servlet-api’ dependency  is not in your pom.xml file.

You can add the below commands to add the dependency in your pom.xml file.

<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->

<dependency>

    <groupId>javax.servlet</groupId>

    <artifactId>javax.servlet-api</artifactId>

    <version>4.0.1</version>

    <scope>provided</scope>

</dependency>

The above command will help you to download the latest version of your ‘javax.servlet-api’ dependency.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...