I’m trying to use eclipse for Java EE to develop web applications.
I need to use Tomcat as my server. I’ve downloaded Tomcat and it’s running. But my program doesn’t compile.
I get the following error:
The import javax.servlet can’t be resolved.
What do I need to do?
You need to add the Servlet API to your classpath. In Tomcat 6.0, this is in a JAR called
servlet-api.jarin Tomcat’slibfolder. You can either add a reference to that JAR to the project’s classpath, or put a copy of the JAR in your Eclipse project and add it to the classpath from there.If you want to leave the JAR in Tomcat’s
libfolder:servlet-api.jarand select it.Or, if you copy the JAR into your project:
servlet-api.jarin your project and select it.