• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Cant run a Servlet

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I've installed Tomcat4.1.12 and j2sdk1.4.0_02and the class file is in the ROOT directory which is in the Tomcat software itself. The context path in servlet.xml was set to "ROOT".
The java servlet class file is stored in the directory:
c:\Tomcat\webapps\ROOT\WEB-INF(web.xml)\classes\HelloWorld.class
The web.xml file for HelloWorld is in the dir WEB-INF. classes is a dir created by me.
HelloWorld.java doesnt have any errors. Compilation was successful but cant run the Servlet. When i type the URL:
http://localhost:8080/ROOT/servlet/HelloWorld
it says :
HTTP Status 404 - /ROOT/servlet/HelloWorld
--------------------------------------------------------------------------------
type Status report
message /ROOT/servlet/HelloWorld
description The requested resource (/ROOT/servlet/HelloWorld) is not available.

--------------------------------------------------------------------------------
Apache Tomcat/4.1.12
instead of getting HelloWorld on the webpage.
Can you plz help me why iam getting this type of error even though the class path is set correctly.my Email Id is pavanisanni@yahoo.com
Thanks
Pavani.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two things
1. You don't have to include ROOT in the URL
2. If you are going to use the /servlet/ClassName method of invoking a servlet you have to have the "invoker servlet" turned on. Tomcat used to be distributed with this function turned on so all the old books and articles assume it.
Look in the /conf/web.xml file for entries related to the "invoker" servlet.
Bill
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
William, do you know why they started turning the invoker servlet off?
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They put the invoker servlet off for security reasons
 
I'm a lumberjack and I'm okay, I sleep all night and work all day. Lumberjack ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic