I am using JavaSE6 and Eclipse, there is an error in the line
import javax.servlet.*
It seems there is no jar for this import.
How to fix it? Install anything, use Eclipse EE or add some dependency in Maven?
The servlet API is not a part of the JDK, you need to add an additional dependency to your pom.xml
.
If this is for a webapp you can add this dependency with provided
scope and the servlet container will make these classes available to your webapp at deployment time.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
javax.servlet.*
is part of the Servlet API (which is part of the Java EE framework). Web Application Server/Web Containers wishing to use Servlets must implement the Servlet API.
Tomcat has servlet-api.jar
which can be found under TOMCAT_HOME/lib
(in Tomcat 6 and higher).
Find one that's relevant to you based on the Web Application Server you're running.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With