1

I have created one sample jsp file using eclipse. Then eclipse is showing one error "The superclass javax.servlet.http.HttpServlet was not found ".

According to The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path , I have done the following . Project Properties-> Java Build Path-> Add Library -> Select "Server Runtime" from the list-> Next->Select "Apache Tomcat"-> Finish

and it worked fine. But I don't understand the use of this procedure. Please tell me why we are adding server runtime library to java build path.

Community
  • 1
  • 1
Neetu
  • 29
  • 1
  • 5
  • So that you can, err, compile Servlets? – user207421 Dec 05 '16 at 20:37
  • I wrote only one jsp file. While saving that file eclipse is showing the above mentioned error. After doing Project Properties-> Java Build Path-> Add Library -> Select "Server Runtime" from the list-> Next->Select "Apache Tomcat"-> Finish , that error message disappeared. I have no idea about why did the error msg disappear after doing the above mentioned steps. – Neetu Dec 07 '16 at 07:25

2 Answers2

1

I got the correct answer. Actually at the time we create a project in eclipse , we can select targeted runtime . That is one installed server name. So ecilpse will take care of adding libraries to the build path. we don't need to add tomcat server library to build path.

If we are not selecting targeted runtime during project creation we can do by the following steps. -go to project > properties >Targeted runtimes > then select the appropriate server.

The target server setting is the default mechanism for setting the class path for J2EE projects. please read the link http://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.jst.j2ee.doc.user%2Ftopics%2Ftjtargetserver.html .

Neetu
  • 29
  • 1
  • 5
0

The answer is pretty simple. When we create a new dynamic web project, eclipse asks us for adding a target runtime which is required for adding the libraries to the build path. If we add the target server runtime environment while creating the project then the jsp's will not show the error 'The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path'.

You can also later set the runtime environment by right clicking on the project -> properties -> target runtime -> Check the runtime environment you are using -> click apply

Check link for more detailed explaination http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.jst.j2ee.doc.user%2Ftopics%2Ftjtargetserver.html

Hetal Rachh
  • 1,393
  • 1
  • 17
  • 23