This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Directory Error

 
Pradipta Ghosh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64701
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pradipta Ghosh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic