I got an error while creating a servlet in eclipse like
Multiple markers at this line
- ServletException cannot be resolved to a type
- HttpServletResponse cannot be resolved to a type
- HttpServletRequest cannot be resolved to a type
Use the @WebServlet annotation to define a servlet component in a web application. This annotation is specified on a class and contains metadata about the servlet being declared. The annotated servlet must specify at least one URL pattern. This is done by using the urlPatterns or value attribute on the annotation.
The javax. servlet. http package contains a number of classes and interfaces that describe and define the contracts between a servlet class running under the HTTP protocol and the runtime environment provided for an instance of such a class by a conforming servlet container.
You can do the folllwoing: import the jar file inside you class:
import javax.servlet.http.HttpServletResponse
add the Apache Tomcat library as follow:
Project > Properties > Java Build Path > Libraries > Add library from library tab > Choose server runtime > Next > choose Apache Tomcat v 6.0 > Finish > Ok
Also First of all, make sure that Servlet jar is included in your class path in eclipse as PermGenError said.
I think this will solve your error
Two possible issues could be
To include Servlet jar in your class path in eclipse, Download the latest Servlet Jar and configure using buildpath option. look at this Link for more info.
If you have included the jar make sure that your import is declared.
import javax.servlet.http.HttpServletResponse
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