IntelliJ Java IDE
The moose likes Tomcat and the fly likes topcat and adding new directory in webapps Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Reply Bookmark "topcat and adding new directory in webapps" Watch "topcat and adding new directory in webapps" New topic
Author

topcat and adding new directory in webapps

david allen
Ranch Hand

Joined: Sep 27, 2002
Posts: 185
I am working on a new site called Lampoons. I wish to store all of the sites required files(jsp, servlets, classes, html) in this directory. I have created a new directory called "Lampoons" in webapps but I am unable to get the default index.html page in this directory(Lampoons) to load.
Do I have to update the server.xml file and if so how? I mean what do I have to insert in there and where?
Thank you so much.
Really like this site
david
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

Yes, unless you plunk your folder under the ROOT web app (which you don't want to do since that will just add your stuff to an existing web app rather than creating a new one of your own), you need to define a new 'context'.
For Tomcat, the following example (lifted from my server.xml) shows a new context definition.

The context is declared within the <Host> element of the server.xml file.
Once Tomcat is restarted, the url http://myserver:8080/trf/ would be used to access the new context (correct server name and port substituted, of course).
Be sure that the web app located at the specified folder follows servlet spec conventions (WEB-INF and all that stuff).
hth,
bear
P.S. Curse you and your typo! Now I've got the theme song from Top Cat playing in my head and I can't get rid of it!
[ July 03, 2003: Message edited by: Bear Bibeault ]

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 11863
As I understand it, Tomcat will not recognize your new directory as a "web application" if it does not have a WEB-INF with a web.xml file in it.
You should not have to modify server.xml, just create WEB-INF and web.xml
Bill


Java Resources at www.wbrogden.com
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

To join my and William's seemingly conflicting posts:
You need the context declaration in server.xml if your folder doesn't exist under the Tomcat webapps folder (my example).
You don't need it (William's point) if you plunk the folder under webapps and it conforms to servlet standards (WEB-INF, web.xml and so on).
hth,
bear
david allen
Ranch Hand

Joined: Sep 27, 2002
Posts: 185
thanks guys.
have it working
david
 
 
subject: topcat and adding new directory in webapps
 
Threads others viewed
servlets and new web directory
response.sendRedirect problem
root tomcat
problem while running servlet
Is WEB-INF Directory mandatory ?
MyEclipse, The Clear Choice