Solved

How to run my servlets using tomcat 5.0

Posted on 2003-12-09
10
781 Views
Last Modified: 2013-11-24
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

0
Comment
Question by:malli143
10 Comments
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
Give an entry for this servlet in web.xml
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
or alternately (a bad way), use: http://localhost:8080/servlet/YourServletClassName - but it might not be allowed on all versions of Tomcat.
0
 
LVL 24

Expert Comment

by:shivsa
Comment Utility
have u setup the CLASSPATH variable.
0
 
LVL 24

Expert Comment

by:shivsa
Comment Utility
You should add to your classpath the servlet.jar and the "." (current directory)
Ex: CLASSPATH=.;tomcat-install-dir/common/lib/servlet.jar
0
 
LVL 24

Expert Comment

by:shivsa
Comment Utility
Also you should uncomment the lines in the tomcat-install-dir/conf/web.xml that say: <servlet-mapping>
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
I guess Tomcat also comes with a setclasspath batch file - you can make use of that too, if its a class-path problem.
0
 
LVL 9

Expert Comment

by:Ovi
Comment Utility
Look at the servlet examples in Tomcat and follow web.xml file there. Should work.
0
 

Author Comment

by:malli143
Comment Utility
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
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
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
 
LVL 30

Accepted Solution

by:
mayankeagle earned 100 total points
Comment Utility
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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now