• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Directory Error

 
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.
 
Marshal
Posts: 67279
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!