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

Unable to load servlet in Tomcat 5.5

Narasimha Sharma

Joined: Jul 04, 2011
Posts: 6

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


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" "">





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

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

You put the context root of your web app in ROOT. This is wrong. It belongs in webapps; ROOT is its own application.

[Asking smart questions] [About Bear] [Books by Bear]
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
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.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Welcome to the JavaRanch, Narasimha!

An IDE is no substitute for an Intelligent Developer.
Narasimha Sharma

Joined: Jul 04, 2011
Posts: 6
Thanks Bear !! It worked when I moved the folder to webapps rather than webapps->ROOT ..

Thanks Tom for the welcome !!
parni raghuvanshi

Joined: Jun 21, 2011
Posts: 14
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.
I agree. Here's the link:
subject: Unable to load servlet in Tomcat 5.5
It's not a secret anymore!