This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Directory Error 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 » Java » Servlets
Bookmark "Directory Error" Watch "Directory Error" New topic

Directory Error

Pradipta Ghosh

Joined: Nov 03, 2007
Posts: 7

I am new to Servlet Programming.
I have prepared a directory under tomcat/webapps/ch1/WEB-INF/classes. Where I put the classfile in classes and web.xml file in WEB-INF. I run it by typing http://localhost:8080/ch1/Serv1. It is showing the desired result.
But If I make the directory structure as tomcat/webapps/HeadFirst/ch1/WEB-INF/classes and run by typing http://localhost:8080/HeadFirst/ch1/Serv1, it is giving error. Why?
Can't I put ch1 folder inside any other folder like HeadFirst. I don't want to keep it directly under webapps.

Thanks in advance.

N.B. /Serv1 is the url-pattern for Servlet-mapping in xml file.

Pradipta Kumar Ghosh
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60743

WEB-INF must be in the root of the web app. It cannot be nested deeper.

If you want to put your app elsewhere on the disk you can do so by explicitly mapping it via a context declaration. The Tomcat documentation explains how.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pradipta Ghosh

Joined: Nov 03, 2007
Posts: 7
Thanks Bibeault for your reply.
I have tried my hand in Tomacat Documentation for context path mapping, but couldn�t succeed.
I tried with:
Deploy A New Application Remotely

Start An existing Application

And run by typing http://localhost:8080/ch1/Serv1.

I have got another solution. I changed in tomcat6/conf/server.xml.

<Host name="localhost" appBase="webapps/HeadFirst"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">

Now my directory structure is tomcat/webapps/HeadFirst/ch1/WEB-INF/classes
And I run it by typing http://localhost:8080/ch1/Serv1. It is showing the desired result.
But other application which is directly under webapps didn�t working.

So if you please explain with an example.
Thanks in advance.
wood burning stoves
subject: Directory Error
Similar Threads
404 error
Error 404 while requesting for a page
Running self made Servlets on tomcat
Having trouble getting Tomcat up and running