malli143
asked on
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/class es and tried to run from the browser. But it didn't work.
Can any one help me on this
Chandu
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/class
Can any one help me on this
Chandu
Give an entry for this servlet in web.xml
or alternately (a bad way), use: http://localhost:8080/servlet/YourServletClassName - but it might not be allowed on all versions of Tomcat.
have u setup the CLASSPATH variable.
You should add to your classpath the servlet.jar and the "." (current directory)
Ex: CLASSPATH=.;tomcat-install -dir/commo n/lib/serv let.jar
Ex: CLASSPATH=.;tomcat-install
Also you should uncomment the lines in the tomcat-install-dir/conf/we b.xml that say: <servlet-mapping>
I guess Tomcat also comes with a setclasspath batch file - you can make use of that too, if its a class-path problem.
Look at the servlet examples in Tomcat and follow web.xml file there. Should work.
ASKER
Also you should uncomment the lines in the tomcat-install-dir/conf/we b.xml that say: <servlet-mapping>
if I try to modify this , tomcat is not starting
if I try to modify this , tomcat is not starting
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.
Alternatively (just for testing), you can use the second approach which I had suggested earlier.
Mayank.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.