File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes HelloServlet  not running ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "HelloServlet  not running ?" Watch "HelloServlet  not running ?" New topic

HelloServlet not running ?

raghu tv

Joined: Feb 25, 2003
Posts: 9
i am using Tomcat 4.1
i am able to run HTML and JSP from browser.
But i am unable to run the servlet........
i kept the HelloServlet.class in the
and http://localhost:8080/servlet/HelloServlet
is not working.Actually there was no classes
directory in WEB-INF i created it and kept the class file in it. is that it wont work with higher versions of Tomcat ? then what i have to do......
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
You have to prepare a web.xml file and put it in the WEB-INF directory to run servlets. Here is an example of web.xml:

[ February 25, 2003: Message edited by: JiaPei Jen ]
raghu tv

Joined: Feb 25, 2003
Posts: 9
thanku for the response
i kept your web.xml in WEB-INF directory but already a web.xml file is there in it anyhow i kept both the xml files but still i am getting the 404 error
Dave Jochim
Ranch Hand

Joined: Jan 08, 2003
Posts: 31
I think you can do one of two things.
1. Use servlet mapping in the web.xml of your web application like JiaPei Jen began explaining.
2. In tomcat's web.xml under the /conf directory. You can uncomment the mapping for invoker servlet and then it should work like were hoping in your first posting with http://localhost:8080/servlet/HelloServlet.
Here is a link where they addressed the same problem, and the explanation is in more capable hands than mine.
raghu tv

Joined: Feb 25, 2003
Posts: 9
once again thank u for ur response.Both the things didnot work....
1)i made the web.xml as follows in WEB-INF directory
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
<display-name>Welcome to Tomcat</display-name>
Welcome to Tomcat
- <servlet>
- <servlet-mapping>
but still my servlet is not working .
2) i removed the comments for the invoker servlet in tomcat's web.xml under conf directory
but still it ia not working
3) and the link u gave is very complex to understand .please help me in solving the problem
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

take those '-' out of your web.xml file. IE will add little plus and minus signs to XML files when it displays in a browser. If you copy and paste directly, you get the - and + symbols. It's not good to have them.
[ March 03, 2003: Message edited by: Mike Curwen ]
raghu tv

Joined: Feb 25, 2003
Posts: 9
i am sorry Mike even after removing the '-'s from web.xml i am getting the 404 error. not able to get the page . please help..........
praveen patil

Joined: Mar 03, 2003
Posts: 9
i had encountered same problem with 4.1 vers.
then i changed location from the one to <HOME>/
webapps/examples/WEB-INF/classes for testing
purpose & it worked fine. then u need to
configure server.xml,web.xml to make ur own
dont forget to change context path.type in brw.<port pt>/examples/servlet/urfile.class

good luck.
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
raghu tv,
Take another look at the aforementioned thread. I just posted the exact steps I used to resolve this issue on my installation of Tomcat 4.1.
Oh, and...
Welcome to JavaRanch, raghu tv!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: HelloServlet not running ?
It's not a secret anymore!