my dog learned polymorphism*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "HelloServlet  not running ?" Watch "HelloServlet  not running ?" New topic
Author

HelloServlet not running ?

raghu tv
Greenhorn

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
Tomcat\webapps\ROOT\WEB-INF\classes.
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
Greenhorn

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. http://www.coderanch.com/t/82236/Tomcat/requested-resource-not-availabe
raghu tv
Greenhorn

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"
"http://java.sun.com/dtd/web-app_2_3.dtd">
-<web-app>
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
- <servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>
- <servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/servlet/HelloServlet</url-pattern>
</servlet-mapping>
</web-app>
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
Greenhorn

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
Greenhorn

Joined: Mar 03, 2003
Posts: 9
hi,
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
pckgs.
dont forget to change context path.type in brw.
http://www.xxx.:<port pt>/examples/servlet/urfile.class

good luck.
Praveen
Dirk Schreckmann
Sheriff

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]
 
Consider Paul's rocket mass heater.
 
subject: HelloServlet not running ?
 
Similar Threads
Problems Running Servlet code on Win 2000
unable to compile
Can not run a servlet class
where to put servlets? (searched 1st)
Testing First Servlet....please help