I use Apache Tomcat (5.5.9) to host the website (xyz.com) along with a couple of sub-domains (photos.xyz.com and documents.xyz.com). You can find the relevant portion of server.xml file below.
Hosting the websites in this way has lead to two main headaches. 1. I cannot share my Java code between xyz.com, photos.xyz.com and documents.xyz.com: For example, if I have written a simple Java Bean Class and its deployed in Tomcat/webapps/xyz/WEB-INF/classes, the Class is not available to photos.xyz.com and documents.xyz.com. The only way to make it available to all three domains is deploying the Java Bean class in Tomcat/shared/lib or Tomcat/common/lib directories. 2. Problems with session sharing across the domain (xyz.com) and its sub-domains: For example, when a user performs a search on xyz.com, I store the search results in a Java Bean Object in the session. Lets say the user clicks on one of the search results and ends up on a page at documents.xyz.com. Here I won't have access to the Search Results Java Bean object, which I would love to have. These two problems should be pretty common, right? I am wondering how should I structure my application(s) to take care of the above two. Please advise! Thank you, Kristin /* server.xml */ <Host name="xyz.com" appBase="webapps"> <Context path="" docbase="xyz"> </Context> </Host> <Host name="photos.xyz.com" appBase="webapps"> <Context path="" docbase="photos"> </Context> </Host> <Host name="documents.xyz.com" appBase="webapps"> <Context path="" docbase="documents"> </Context> </Host>