Date Created: Mon 01-Jun-2009

Related Document Categories:

Get my WebSphere Application Server course here >> http://www.themiddlewareshop.com/products/



    HttpServlet cannot be resolved to a type when adding a servlet using Eclipse.

    When trying to add a servlet using the Eclipse wizard you find the the generated code results in the compiler throwing an error "HttpServlet cannot be resolved to a type".

    The reason for this is the Eclipse will pick up your current JRE and the servlet api is not installed and referenced in your project because it is implemented by the application server vendors ie Tomcat, WebLogic and Websphere. What you can do is download the GlassFish Server ie Latest J2EE SDK + GlassFish from Sun to get the servlet-api.

    Download the latest J2EE version from Java. At the time of this writing it was GlassFish and SDK Update 7 found at http://java.sun.com/javaee/downloads/index.jsp.

    Download the J2EE version 7 and then you can refer to is as an installed JDK in your projects properties. Or you could download Tomcat and add an external jar to your project pointing to the servlet-api.jar file. If you had WebSphere installed you could use the j2ee.jar file from the WebSphere runtime and the equivalent for WebLogic of JBoss. Personally this is why I like IBM Rational Software Developer/Architect as it does all this for you when you create a Dynamic Web Project as it has automatici facet adding.

    Once you have added the JAR file Eclipse should automatically re-build and the error will go away.

Get my WebSphere Application Server course here >> http://www.themiddlewareshop.com/products/

Steve Robinson - IBM Champion 2013

About Me

Steve Robinson has been working in IT for over 20 years and has provided solutions for many large-enterprise corporate companies across the world. Steve specialises in Java and Middleware.

In January 2013, I was awarded the prestigous 'IBM Champion' accolade.


Read my books?

IBM WebSphere Application Server 8.0 Administration Guide

IBM WebSphere Application Server 8.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Categories

Other Categories