1

Error in java file i am getting as ServletException cannot be resolved to a type

Multiple markers at this line - HttpServletRequest cannot be resolved to a type - HttpServletResponse cannot be resolved to a type

Please le me know if any jar is missing

public void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
            doPost(req,resp);
    }
user3146144
  • 11
  • 1
  • 3

3 Answers3

0

You lack the servlet-api jar provided by your targeted servlet container (for example tomcat)

see How do I import the javax.servlet API in my Eclipse project?

and

Where do I get servlet-api.jar from?

Community
  • 1
  • 1
Gab
  • 7,869
  • 4
  • 37
  • 68
0

You should add the folowing imports to your servlet:

import javax.servlet.http.HttpServletResponse
import javax.servlet.http.HttpServletRequest

And add the following jar into your classpath:

http://download.oracle.com/otndocs/jcp/servlet-3.0-fr-eval-oth-JSpec/

0

Add jsp-api.jar and servlet-api.jar to your build path.

Hunter Zhao
  • 4,589
  • 2
  • 25
  • 39