Servlet Errors in Eclipse
For new users, it’s common to encounter following errors while developing servlet in Eclipse (I am using eclipse-jee-indigo-SR2-win32) or without it:
HttpServlet cannot be resolved to a type
HttpServletRequest cannot be resolved to a type
HttpServletResponse cannot be resolved to a type
ServletException cannot be resolved to a type
The import javax.servlet cannot be resolved
WebServlet cannot be resolved to a type

Java – Download Free EBooks and Whitepapers
The problem is “servlet-api.jar” is not on classpath.
How to add servlet-api.jar in classpath from Eclipse?
Right Click on the Web Project and Click on Properties

Select Java Build Path

Click on the Library Tab

Click on “Add External Jar” -> Locate servlet-api.jar from your local system (It’s available in Tomcat Distribution directory.)


Click OK and all errors will be resolved.

Done!!!
Other Interesting Tomcat related Articles:
- How to Create and Run Web Project (Java) in Eclipse (clean-clouds.com)
- How to Solve Servlet Errors in Eclipse? (clean-clouds.com)
- How to add Tomcat 7.x in Eclipse? (clean-clouds.com)
- How to Export WAR file from Eclipse to Tomcat (clean-clouds.com)
- How to debug Web Application remotely with Eclipse Indigo and Tomcat 7.0.22? (clean-clouds.com)
- Tomcat Server running as Windows service (clean-clouds.com)
- How to customize the location of the tomcat logging.properties file? (clean-clouds.com)
- Install Tomcat 7 or Tomcat 7.0.26 or Tomcat 6 or Tomcat 5 on Ubuntu 11.10 or Ubuntu 11.04 or Ubuntu 10.10 or Ubuntu 10.04 LTS (clean-clouds.com)
Very Helpful, Many Thanks for doing this!
Thank you 🙂
really thanks !!