Reputation: 55
Here's some error im getting on Eclipse
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class HelloServlet extends HttpServlet
It says HttpServlet cannot be resolved to a type , pls help
Upvotes: 2
Views: 12690
Reputation: 11116
If your project is maven then add following dependancy :
<!-- https://mvnrepository.com/artifact/javax.servlet/servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
For gradle projects:
dependencies {
providedCompile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
}
or download javax.servlet.jar
and add to your project.
Steps:
Upvotes: 0
Reputation: 94429
You need to add the runtime libraries from your application server.
For example:
Go to project properties. Click Build Path, then the libraries tab. Click add library, then select Server Runtime. Select your server and click OK.
Upvotes: 6
Reputation: 1150
check project build path whether Servlets api jar file is included or not. you can add it in two ways:
1) add servlets api .jar file to build path
or
2) add server runtime (i add Tomcat server runtime library) in build path
Hope this helps.
Upvotes: 2