aspose file tools*
The moose likes Tomcat and the fly likes Same web app for a.mydomain.com & b.mydomain.com? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Same web app for a.mydomain.com & b.mydomain.com?" Watch "Same web app for a.mydomain.com & b.mydomain.com?" New topic
Author

Same web app for a.mydomain.com & b.mydomain.com?

Joshua White
Ranch Hand

Joined: Jun 04, 2001
Posts: 97
Is it possible to have a single instance of a web app respond to a.mydomain.com and b.mydomain.com?

I am looking to maintain only one code base, but brand/skin my site base on the url.

If this can't be done, is there a better way to do this?

Regards,

Joshua
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

Depends what you mean by "have a single instance".

Can two different domain names share a single instance of a web application on disk?

Yes.

Will the different domains share the same in-memory instance of the application (in other words, will they share the same servlet context)?

No.

Be aware that if your app writes files to folders within the contextm that they could interfere with each other. I'm sure never to do such a thing.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joshua White
Ranch Hand

Joined: Jun 04, 2001
Posts: 97
Bummer. The only other way I can think of to solve this problem is passing a parameter arround (or at least initially) to indicate which company they are associated with.

I don't want to get into the business of deploying multiple copies of this app. Any other suggestions on how to solve this problem?

Regards,

Joshua
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

Here's a contrived example based upon virtual hosts set up in my Tomcat 5 setup:



Notice that both hosts have the same docbase. The hosts could also have idifferent doc bases, but have the context themselves resolve to shared web apps on the disc.
[ May 05, 2005: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

Bummer. ... Any other suggestions on how to solve this problem?


I'm not sure how my answer precludes your doing what you want to be doing given that you've stated that you will do the branding by URL detection.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
Couldn't you look at the request with getServerName() and use different skins depending on the result?
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Same web app for a.mydomain.com & b.mydomain.com?
 
Similar Threads
Images, css and js files
Setting the path of servlet and jsp pages
How to add header and footer to dynamically generated page for print
Specifying relative path
Using JExcel API to create Excel sheet.