This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Tomcat - Host multiple sites? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat - Host multiple sites?" Watch "Tomcat - Host multiple sites?" New topic
Author

Tomcat - Host multiple sites?

Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
I'm hosting a few sites on my Tomcat web server and right now I've written a script (in JavaScript) that redirects the user to the correct sub directory depending on the URL they gave. Does anyone know how I can do this in the Tomcat server.xml file? Thanks in advance.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950
    
  19

What you want is known as virtual hosting. There are 2 ways to do it.
1. Give each site its own unique IP address/port combination
2. Use the hostname-based targer determination that is only supported by HTTP 1.1 clients and higher.
I'm afraid I haven't attempted to do this in standalone Tomcat, so I'd have to RTFM. Using Apache/Tomcat, I setup a standard Apache <VirtualHost> directive block and translate to a unique Tomcat context for each site.


Customer surveys are for companies who didn't pay proper attention to begin with.
Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
I'll have to go with option 2. Thanks for the direction. I'll take a look through docs and Google groups.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Tomcat - Host multiple sites?
 
Similar Threads
URGENT !!sites to download j2ee,weblogic&tomcat
Basic Tomcat Question: Change Port 8080?
Tomcat as standalone server
tomcat in real environment
configure tomcat with iis