• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet doesn't work

 
Ranch Hand
Posts: 168
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
It's been years since the last time I used Tomcat. Now I'm using it again because I'm preparing for the SCWCD exam. I have created a simple servlet and deployed it to Tomcat but it doesn't work. I put the class file in <tomcat-dir>/webapps/myapps/WEB-INF/classes directory. I have created the web.xml file:


I have also set the JAVA_HOME, CATALINA_HOME, and the classpath to the file servlet.jar. But when I try to invoke the servlet using a browser by typing http://localhost:8080/myapps/servlet/myservlet, it shows HTTP status 404. What have I done wrong? Have I missed something?
[ November 02, 2004: Message edited by: Yosi Hendarsjah ]
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Yosi,

Which version of tomcat are you using? For Tomcat 5.0.28 or 5.XXX, the servlet api should be servlet-api.jar instead of servlet.jar. Tomcat 5 is based on Servlet 2.4 and JSP 2.0. Have you uncommented the <servlet> and <servlet-mapping> elements for the invoker in c:\tomcat\conf\web.xml. Also, if you've a servlet.jar under C:\jdk1.5.0\jre\lib\ext, remove or place the jar file in a temporary directory.

For more info on setting up Tomcat 5, you could check out CoreServlets: Installing Tomcat 4 or 5.

Joyce
[ November 02, 2004: Message edited by: Joyce Lee ]
 
Yosi Hendarsjah
Ranch Hand
Posts: 168
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Joyce,
My Tomcat version is 4.1.24. My JVM version is 1.4.2_05
[ November 02, 2004: Message edited by: Yosi Hendarsjah ]
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Yosi,

I suggest you use Tomcat 5.0.28 since the latest SCWCD exam is based on Servlet 2.4 and JSP 2.0 specifications. As for the JDK, you can still use the 1.4 version.

Joyce
[ November 02, 2004: Message edited by: Joyce Lee ]
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Invoker servlet. http://faq.javaranch.com/view?InvokerServlet
 
Yosi Hendarsjah
Ranch Hand
Posts: 168
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Mike! The book I'm reading (Desmukh & Malavia) doesn't mention those.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic