• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HelloServlet not running ?

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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......
 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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. https://coderanch.com/t/82236/Tomcat/requested-resource-not-availabe
 
raghu tv
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..........
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic