Thursday, March 13, 2014

How to resolve javax.servlet.http.HTTPServlet Error in eclipse

When trying to execute a JSP program, javax.servlet.http.HTTPServlet error can be encountered, if eclipse is not connected with the Tomcat server. This can be due to the eclipse not recognizing the server or that eclipse has not been configured with Tomcat.

The error can be as below:





Sorry I had to blur out part of the images to hide the details.

The solution is to first add Tomcat to eclipse and then to configure the build configuration of the project from the package explorer. If Tomcat has been added then skip to point 2 below

1) Adding Tomcat configuration to eclipse:

 In eclipse, click Window --> Preferences

collapse Server and select Runtime Environment



click Add on the right side and select Apache Tomcat (with the version currently being installed) and click Next.

In the Tomcat installation directory, enter the location where Tomcat is being installed



And then click Finish.

Now Tomcat is being configured with eclipse.

2) Resolving the error:

In the Project Explorer pane, right click on the project name, and select Build Path --> Configure Build Path



On the left side select Targeted Runtimes and select Apache Tomcat on the right side. Click OK.

You will see the error disappear!!!

Way to go to code the project....