PDA

View Full Version : Tomcat 5 Virtual Host Default Web App


wf
06-05-2004, 09:45 PM
Hi all...

In server.xml I defined two virtual hosts... call them www.dog.com and www.cat.com. Web apps for dog reside in webapps/dog and for cat in webapps/cat. Actually, I only have one web app for each host. If I put a directory called app in the dog space, like webapps/dog/app, then Tomcat will automatically create a context for it. But then I have to enter www.dog.com/app to get to its index.html file. I just want to define it as a default app, so that www.dog.com maps to index.html of the default (and only) web app in the dog host space. Can anyone point me to info on this subject?

I noticed they don't recommend putting a context tag into server.xml for Tomcat 5. Instead, you're supposed to put a "context fragment", whatever that is, into conf/Catalina/www.dog.com. But couldn't find any examples of this, and whatever experiments I tried didn't work.

Thanks for any help, and thanks to Rimu for adding a forum!

wf
06-06-2004, 04:35 PM
Nevermind... got it working.

retep
06-07-2004, 03:08 AM
What did you end up doing to get it working?

wf
06-07-2004, 03:20 AM
I don't have Apache running. Several weeks ago I followed your "how to" directions to start Tomcat on reboot, and not to run Apache, and to have Tomcat listen on port 80. Don't remember the details. Then...

Made a file:

conf/Catalina/www.dog.com/context.xml

The contents of this file:


<Context path="" docBase="" debug="0"/>


Same with www.cat.com.

The conf/server.xml file has tags like this:


<Host name="www.dog.com" debug="0" appBase="webapps/dog" unpackWARs="false" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">

<Alias>dog.com</Alias>

<Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="Dog_log." suffix=".txt" timestamp="true"/>

</Host>


Similar for the cat host.

Then I put the default (and only) web app for dog in webapps/dog directory, and similar for cat. Now when I go to www.dog.com it serves index.html from webapps/dog, and JSPs and everything else seem to be working properly as well.