views:

176

answers:

3

The Basecamp URL like .basecamphq.com, eg seymores.basecamp.com.

How can I do the same in Tomcat environment?

+1  A: 

The short answer is to parse the host from the request url. Then use that with all of the queries that you make. In the default configuration Tomcat will respond to all of the request that are mapped to the IP it is listening on.

Clint
+2  A: 

If you just want to have one copy of the web application that acts differently depending on the virtual host name that was used, examine the "Host" header. This could be done in a Filter or a dispatcher servlet, depending on what you want to do with the result.

You can have a different copy of the web application for each virtual server by adding Host elements to the Engine element in your server configuration. This creates separate virtual hosts, each with their own independent set of web applications.

erickson
+4  A: 

Other aproximation is use UrlRewriteFilter. Using this filter with few policies you can, for example, convert calls like:

http://username.domain (before url rewriting)

to

http://domain/your_servlet?user=username (after url rewriting)

SourceRebels