Make sure you're including the actual name of the jar file (e.g., /usr/local/apache/tomcat5.5/common/lib/servlet-api.jar) in the CLASSPATH. If you just specify the directory (/usr/local/apache/tomcat5.5/common/lib), it won't work.
I remember this because it took me close to a day to figure it out when I was learning Java... --- Tracy Nelson / Nelnet Business Solutions 402 / 617-9449 | -----Original Message----- | From: athula bogoda [mailto:[EMAIL PROTECTED] | Sent: Wednesday, 20 December, 2006 05:55 | To: Tomcat Users List | Subject: Re: How to Run Servlet | | Thnks it works fine. | | But then why it not works after I set the class path | for the servlet-api.jar file using "Environment | Variables"....... | | Thanks, | Athula | | --- Andre Prasetya <[EMAIL PROTECTED]> wrote: | | > no wonder, add the classpath to servlet, you need to | > ad the servlet-api.jar | > | > e.g : javac -cp d:/path/to/servlet-api.jar | > HelloServlet.java | > | > Athula, I suggest u startoff with an IDE, I | > recommend Netbeans for a | > beginner to servlet. | > | > download the Netbeans5.5 | > | > then new project, choose web project, choose the | > bundled tomcat as the | > server | > | > then new servlet, choose any name, or HelloWorld. | > Then you'll get a starter | > servlet and a mapping | > | > after that you can start running... and you can test | > using a browser. If the | > bundled tomcat port is 1980 then you tried hitting | > http://localhost:1980/<context path>/<mapped | > servlet-name> | > | > for example if my context path is /Dummy and the | > mapped-servlet-name is | > HelloWorld then I hit | > http://localhost:1980/Dummy/HelloWorld | > | > try it.... | > | > I always regard a servlet as a cgi java, if you want | > to do a complex | > programming, i recommend you start with java 1st | > then the servlet and jsp, | > you might wanna take a look at Spring Framework, | > Struts, WebWork or GWT | > | > | > On 12/20/06, athula bogoda <[EMAIL PROTECTED]> | > wrote: | > > | > > Here is the out put. I run it on command prompt. | > > | > > | > > D:\BOGODA\DEVELOPMENT\PRODUCTS\SERVLETS>javac | > HelloServlet.java | > > HelloServlet.java:3: package javax.servlet does | > not exist | > > import javax.servlet.*; | > > ^ | > > HelloServlet.java:5: package javax.servlet.http | > does not exist | > > import javax.servlet.http.*; | > > ^ | > > HelloServlet.java:21: cannot find symbol | > > symbol: class HttpServlet | > > public class HelloServlet extends HttpServlet | > > ^ | > > HelloServlet.java:23: cannot find symbol | > > symbol : class HttpServletRequest | > > location: class HelloServlet | > > public void doGet(HttpServletRequest request, | > > ^ | > > HelloServlet.java:25: cannot find symbol | > > symbol : class HttpServletResponse | > > location: class HelloServlet | > > HttpServletResponse response) | > > ^ | > > HelloServlet.java:27: cannot find symbol | > > symbol : class ServletException | > > location: class HelloServlet | > > throws ServletException, IOException | > > ^ | > > 6 errors | > > | > > Thanks, | > > Athula | > > ======================================== | > > | > > ----- Original Message ---- | > > From: David Delbecq <[EMAIL PROTECTED]> | > > To: Tomcat Users List <users@tomcat.apache.org> | > > Sent: Tuesday, December 19, 2006 6:19:11 PM | > > Subject: Re: How to Run Servlet | > > | > > And please provide the complete terminal output of | > compilation process | > > so we can have an idea what is your problem. | > > Mark Thomas a écrit : | > > > athula bogoda wrote: | > > > | > > >> This is the file i tried to execute. | > > >> | > > >> I also set the class path for jsp-api.jar and | > servlet.jar files. | > > >> But it did not work. | > > >> | > > > | > > > Your servlet needs to be in a package. | > > > | > > > Next, how did you try and compile it when you | > got the "Cannot find | > > > symbols." error? | > > > | > > > Mark | > > > | > > > | > > > | > > > | > > > | > | --------------------------------------------------------------------- | > > > To start a new topic, e-mail: | > users@tomcat.apache.org | > > > To unsubscribe, e-mail: | > [EMAIL PROTECTED] | > > > For additional commands, e-mail: | > [EMAIL PROTECTED] | > > > | > > > | > > | > > | > > | > | --------------------------------------------------------------------- | > > To start a new topic, e-mail: | > users@tomcat.apache.org | > > To unsubscribe, e-mail: | > [EMAIL PROTECTED] | > > For additional commands, e-mail: | > [EMAIL PROTECTED] | > > | > > | > > | > > | > > | > > | > > | > > Send instant messages to your online friends | > http://uk.messenger.yahoo.com | > > | > | > | > | > -- | > -Andre- | > | > People see things the way they are and say "why ?" I | > see things that never | > were and say "Why not ?" | > | | | Send instant messages to your online friends http://uk.messenger.yahoo.com | | --------------------------------------------------------------------- | To start a new topic, e-mail: users@tomcat.apache.org | To unsubscribe, e-mail: [EMAIL PROTECTED] | For additional commands, e-mail: [EMAIL PROTECTED] The information contained in this message is confidential proprietary property of FACTS/Nelnet Business Solutions. Any reproduction, forwarding, or copying without the express permission of FACTS/Nelnet Business Solutions is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to this e-mail. --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]