How to run my servlets using tomcat 5.0

Hi

How do I run my servlet programs in Tomcat 5.0. I have done the following as of now

1. I hace installed Tomcat 5.0 successfully. If i give 'http://localhost:8080/" in my browser i am getting the tomcat page and hence i can say tomcat is running

2. I installed j2sdk1.4.2_02 and I compiled my servlet successfully.

Now I have the class file of my servlet and I don't know how to run this servlet using tomcat 5.0.
I put this class file in webapps/ROOT/WEB-INF/classes and tried to run from the browser. But it didn't work.

Can any one help me on this



Chandu

malli143Asked:
Who is Participating?
 
Mayank SAssociate Director - Product EngineeringCommented:
Please visit:

http://www.experts-exchange.com/Programming/Q_20803831.html

Might be helpful. It has en entire detailed sequence of steps to be followed while deploying a servlet in Tomcat. Please go through the comments.

Mayank.

0
 
Mayank SAssociate Director - Product EngineeringCommented:
Give an entry for this servlet in web.xml
0
 
Mayank SAssociate Director - Product EngineeringCommented:
or alternately (a bad way), use: http://localhost:8080/servlet/YourServletClassName - but it might not be allowed on all versions of Tomcat.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
shivsaCommented:
have u setup the CLASSPATH variable.
0
 
shivsaCommented:
You should add to your classpath the servlet.jar and the "." (current directory)
Ex: CLASSPATH=.;tomcat-install-dir/common/lib/servlet.jar
0
 
shivsaCommented:
Also you should uncomment the lines in the tomcat-install-dir/conf/web.xml that say: <servlet-mapping>
0
 
Mayank SAssociate Director - Product EngineeringCommented:
I guess Tomcat also comes with a setclasspath batch file - you can make use of that too, if its a class-path problem.
0
 
OviCommented:
Look at the servlet examples in Tomcat and follow web.xml file there. Should work.
0
 
malli143Author Commented:
Also you should uncomment the lines in the tomcat-install-dir/conf/web.xml that say: <servlet-mapping>
 if I try to modify this , tomcat is not starting
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Can you post the content from your web.xml file? The entire part from <servlet-mapping> to </servlet-mapping>, if commented, needs to be uncommented. And you need to add an entry for your Servlet in that file.

Alternatively (just for testing), you can use the second approach which I had suggested earlier.

Mayank.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.