Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet doesn't work

 
Yosi Hendarsjah
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • 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 ]
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • 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: 166
  • Mark post as helpful
  • send pies
  • 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
  • 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 ]
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Invoker servlet. http://faq.javaranch.com/view?InvokerServlet
 
Yosi Hendarsjah
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Mike! The book I'm reading (Desmukh & Malavia) doesn't mention those.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic