If you are facing this error after importing an existing maven project into your eclipse IDE, then it means that http-servlet is not available in the project’s classpath and you must include it.
The error looks like this.
To include http-servlet into your classpath, you have two options.
1. Add Target Server Runtime
In this solution, you can add desired server runtime into your application as a project facet. As runtime servers have already servlet runtime dependencies, they get included in your project and hence the error is gone.
2. Add Maven Dependency
Another option is to include the servlet-api dependency through maven itself. This will also fix the error.
Do not forget to run
mvn update command after including the dependencies.
<dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency>
Happy Learning !!