| Author |
My first servlet program -execution
|
Vishwanath Krishnamurthi
Ranch Hand
Joined: Jun 04, 2007
Posts: 331
|
|
Hi ranchers, I am just starting with servlets now and tried this program: (from complete reference java, Herbert Schildt) I compiled this and placed the class file in f:\tomcat\webapps\try\WEB-INF\classes\ Then tried http://localhost:8080/try/servlet/HelloServlet in the browser... and all I get is a HTTP Status 404 with the description:The requested resource (/try/servlet/HelloServlet) is not available. Can you please guide me... http://localhost:8080/ works fine though, I am able to see the default tomcat page and was able to execute the servlet examples provided by tomcat... So I'm assuming that I've specified JAVA_HOME, CATALINA_HOME variables properly...
|
Blog
|
 |
Siddharth Naik
Ranch Hand
Joined: Apr 09, 2006
Posts: 35
|
|
It appears that you are trying to create a web application. In that case: extend HttpServlet, override doGet() or doPost()methods and use HttpServletRequest and HttepServletResponse objects as parameters. http://java.sun.com/developer/onlineTraining/Programming/BasicJava1/servlet.html
|
Thanks<br />Sid
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
I'm guessing that's a pretty old book. From the URL, I'm assuming that it's assuming that you have the InvokerServlet enabled. In all the the oldest versions of Tomcat that feature has been disabled. If the book covers creating servlet entries and servlet mappings in web.xml, try doing that and see if it works. If not, we have demo application that's all packaged up and ready to go in our codeBarn. Download SimpleServlet.war to your TOMCAT/webapps directory and Tomcat will unpack and deploy the application for you. Once it does, you can look at TOMCAT/webapps/SimpleServlet/WEB-INF/web.xml to see how it was done. Hope this helps.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
|
http://faq.javaranch.com/java/CodeBarnSimpleServlet
|
 |
Vishwanath Krishnamurthi
Ranch Hand
Joined: Jun 04, 2007
Posts: 331
|
|
Hi, thanks... Ya, thats an old book... Earlier I had tried an example from "Head first Servlets & JSP" and that wasn't working too... I had done some mistakes in web.xml while typing, I guess... Tried editing the web.xml in this codebarn servlet example and used it... and it works perfectly now! thanks...
|
 |
 |
|
|
subject: My first servlet program -execution
|
|
|