• 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

Unable to load servlet in Tomcat 5.5

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi...

I'm using tomcat 5.5 for the first time. I have a jdk6 installed in my system. When I try to deploy a servlet, it is not getting picked up in the browser.

I have created a directory structure like this

WebApps
|
|
V
ROOT
|
|
---Sample
|
|
---index.html
|
WEB-INF
|
---web.xml
|
classes
|
----HelloServlet.class




This is a copy of my web.xml :

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>

<servlet>
<servlet-name>myHello</servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>myHello</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>

</web-app>


Link Tag my index.html :

<A HREF="hello">Run HelloServlet</A>


I get this error when I click the "Run HelloServlet" link :

HTTP Status 404 - /Sample/hello

type Status report

message /ch1/hello

description The requested resource (/ch1/hello) is not available.
Apache Tomcat/5.5.33


 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You put the context root of your web app in ROOT. This is wrong. It belongs in webapps; ROOT is its own application.
 
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
Also classic error:


All classes used in servlets must be defined in packages and the compiled class file stored appropriately. Reason being that the JVM looks in the "current" directory for default package classes and you have NO control over the current directory with servlets.

See also FAQ on the dreaded Invoker servlet.

Bill
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Narasimha!
 
Narasimha Sharma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear !! It worked when I moved the folder to webapps rather than webapps->ROOT ..

Thanks Tom for the welcome !!
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello sir,previously i was using eclipse but it did not work good,so i suggest to install tomcat server & work in notepad but i do not know why tomcat server is not running,after installing tomcat when i click on the start an icon named "monitor tomcat" is seen ,when i click on it a message was encountered "access is denied unable to open the service tomcat 6.0".I downloaded it many times but same problem got occured.can you help me & give some suggestions.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic