• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet Compiling Problems

 
srikant sahoo
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've installed TOMCAT 5.0 and J2SDK 1.4.2_06 n i've set my path.

I've created myproject folder, then WEB-INF and then classes folder and web.xml file.

I created HelloWorldServlet.java. and tried to compile it. But after compilation the follwing errors come

1. HelloWorldServlet.java:4: package javax.servlet does not exist
import javax.servlet.*;

2. HelloWorldServlet.java:5: package javax.servlet.http does not exist
import javax.servlet.http.*;

3. HelloWorldServlet.java:7: cannot find symbol
symbol:class HttpServlet
public class HelloWorldServlet extends HttpServlet {

4. HelloWorldServlet.java:9: cannot find symbol
symbol:class HttpServletRequest
location : classHelloWorldServlet
public void doGet(HttpServle. tRequest request, HttpServletResponse response)

5. HelloWorldServlet.java:9: cannot find symbol
symbol:class HttpServletRequest
location : classHelloWorldServlet
public void doGet(HttpServle. tRequest request, HttpServletResponse response)

6. HelloWorldServlet.java:10: cannot find symbol
symbol : class ServletException
location : class HelloWorldServlet
throws IOException, ServletException

6 errors.

Can anybody help me to resolve this problem.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure j2ee.jar (or servlet.jar) is in your CLASSPATH.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With Tomcat 5x it's servlet-api.jar, found in TOMCAT_HOME\common\lib.
 
srikant sahoo
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sturrock:
Make sure j2ee.jar (or servlet.jar) is in your CLASSPATH.


I've made my classpath as C:\TOMCAT 5.0\common\lib\servlet-api.jar;

Still then this prob persists.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may need to put quotes around it because of the spaces in the path.
set CLASSPATH=%CLASSPATH%;"C:\TOMCAT 5.0\common\lib\servlet-api.jar"

If you are setting from the 'Environment Variables' section in 'My Computer' you will need to fire up a new command window for the enviromnent variable to be active.

Test by typing, from the command line:
echo %CLASSPATH%
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!