Jeba Prince Jeba Prince - 1 year ago 154
Java Question

HttpServlet cannot be resolved to a type .... is this a bug in eclipse?

Every thing was fine and i was able to run this JSP project,
suddenly some thing happened and mostly all my servlets getting unresolved error.

I know its because specific JAR file cant be found for compilation.. but my "buildpath" is fine and i didnt make any changes..

I am stuck in this situation...


  1. cleaned project many times

  2. removes and added JRE library

  3. removed and added server(Tomcat 7.0.23)

Answer Source

You have to set the runtime for your web project to the Tomcat installation you are using; you can do it in the "Targeted runtimes" section of the project configuration.

In this way you will allow Eclipse to add Tomcat's Java EE Web Profile jars to the build path.

Remember that the HttpServlet class isn't in a JRE, but at least in an Enterprise Web Profile (e.g. a servlet container runtime /lib folder).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download