The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Running servlet in Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Running servlet in Tomcat" Watch "Running servlet in Tomcat" New topic

Running servlet in Tomcat

Leena Diwan
Ranch Hand

Joined: Jun 18, 2001
Posts: 351
Hello Friends,

I have problem running the servlet in Tomcat.

I have included servlet and servlet-mapping elements in the DD

Earlier I had not put the servlet in any package. I also tried putting the class file in a folder and giving it as its package name.

I created a webapps/trials dir and put all my stuff there.

Anyone knows what else can I check?

Im getting the famous
Apache Tomcat/4.0.1 - HTTP Status 404 - /trials/TestServlet error!


Leena Diwan
Ranch Hand

Joined: Jun 18, 2001
Posts: 351
Exact error is - 'The requested resource (/trials/TestServlet) is not available.'
Phani Kumar Sripada

Joined: Aug 14, 2003
Posts: 5
Hi Leena,

Make sure the following are in place.

i) All the Servlet classes are under webapps/trials/WEB-INF/classes directory.
ii) The DD web.xml is in webapps/trials/WEB-INF directory.


SCJP 1.4
kriti sharma
Ranch Hand

Joined: Feb 16, 2001
Posts: 160
Leena : me too same error on tomcat 5.0.19

Phani : i have everything in correct place as you have pointed,still the same error.
Ritesh Agrawal
Ranch Hand

Joined: Jan 08, 2004
Posts: 74
I have tried the same and for me it works. I have done the following:

1. Coded the servlet class (Didn't use any package).
2. Compiled and placed it in webapps/trial/WEB-INF/classes/ directory.
3. Made following entries into webapps/trial/WEB-INF/web.xml file

4. Started the Tomcat 5.0.19 application.
5. Entered the following URL http://localhost:8080/trial/TestServlet

and Bingo!!! It works.

I believe, in your case there would have been some problem with the web.xml entries. Usually that's the place where most people make mistakes.

Hope it helps.

Ritesh<br /> <br />SCJP 1.4<br />IBM Test 340<br />IBM AIX V4.0 Certified Professional<br /> <br />Right actions for the future are the best apologies for wrong ones in the past.<br />- Tyron Edwards
Leena Diwan
Ranch Hand

Joined: Jun 18, 2001
Posts: 351
I was using tomcat 4.0 The problem was with the invoker servlet mapping in the conf/Web.xml file.

I have run the servlets with myApp/servlet/TestServlet URL instead of myApp/TestServlet

I agree. Here's the link:
subject: Running servlet in Tomcat
It's not a secret anymore!