wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes setting classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply locked New topic
Author

setting classpath

ks karthe
Greenhorn

Joined: Jun 17, 2008
Posts: 14
hi everyone,

i am new to servlet
i am reading K&B book for SCWCD.
i tried to run the program (chapter 1 ,page no 30)
but its showing 5 errors


Ch1Servlet.java:1: package javax.Servlet does not exist
import javax.Servlet.*;
^
Ch1Servlet.java:2: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
Ch1Servlet.java:5: cannot find symbol
symbol: class HttpServlet
public class Ch1Servlet extends HttpServlet
^
Ch1Servlet.java:7: cannot find symbol
symbol : class HttpServletRequest
location: class Ch1Servlet
public void goGet(HttpServletRequest request, HttpServletResponse response)
throws IOException
^
Ch1Servlet.java:7: cannot find symbol
symbol : class HttpServletResponse
location: class Ch1Servlet
public void goGet(HttpServletRequest request, HttpServletResponse response)
throws IOException

i set the classpath as said in the book.
i read some other posts regarding this probelm and tried to solve
but in vain.

please some one help
thanks in advance
thank you all
Antonio Tercero
Ranch Hand

Joined: Jun 05, 2008
Posts: 110
If your are new to servlets, you should download and install Netbeans IDE first:
it comes with tomcat,glassfish and it's all configured.


SCJP 5, SCWCD 5
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Include the servlet-api.jar file in your lib folder.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1

Hi,

You are missing the servlet.jar in your CLASSPATH environmental variable.

Cheers,
Raj.
Ravi Singh
Greenhorn

Joined: Jun 02, 2008
Posts: 26
Please add servlet-api.jar present in your tomcats common/lib folder and add it to the classpath by using environment varables settings in your system.

Problem is tomacat is not able to find the APIs related to servlets since they are not on classpath .

Above solution will work for any web project running inside Tomcat
ks karthe
Greenhorn

Joined: Jun 17, 2008
Posts: 14
thank you everyone
now it compiled fine , but still its showing HTTP status 404 error
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

The page you are trying to access is not located. Try restarting Tomcat or check if you really have the jsp/html page that you are accessing. Look at your web.xml.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Closing duplicate


[My Blog]
All roads lead to JavaRanch
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: setting classpath
 
Similar Threads
Problems installing Tomcat/XP
Error while compiling
Servlet compilation error
compile errors
problem with TOMCAT_HOME configration