This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft 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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Directory Error" Watch "Directory Error" New topic
Author

Directory Error

Pradipta Ghosh
Greenhorn

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
Marshal

Joined: Jan 10, 2002
Posts: 60077
    
  65

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
Greenhorn

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
http://localhost:8080/manager/deploy?path=/HeadFirst

Start An existing Application
http://localhost:8080/manager/start?path=/HeadFirst

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Directory Error
 
Similar Threads
Error 404 while requesting for a page
HFSJ Help
404 error
Having trouble getting Tomcat up and running
Running self made Servlets on tomcat