Skinning a webapp

I've been tasked with finding a solution to the following problem

We have multiple customers, each of whom want an individual look/feel on their site. This will be done via css/images.

There should only be one copy of the webapp WAR deployed

Each of the sites will have its own unique URL.

The server should be smart enough to look at the url, use the WAR for some things, and look at a customised copy of things like css and images for another.

I have been told that Tomcat will do this, but can't find any reference to it in the docs. I have found the section on [url http://tomcat.apache.org/tomcat-5.0-doc/config/host.html#Host%20Name%20Aliases]host name aliases[/url] but it doesn't seem to be quite right - mapping multiple urls to thesame war where we want some of the files to be different.

We are currently using JBoss4.0 which is using Tomcat5 under the hood. I have tried looking up virtual hosts, but that seems the same as Tomcat Hostname aliases.

Can anybody shed any light on this subject?

Any references I should look at?

I'm not sure that the request is possible, or is it possible maybe with the addition of Apache Webserver into the equation?

Thanks,

evnafets

[1264 byte] By [evnafetsa] at [2007-10-3 7:38:44]
# 1

Hi Evnafets,

Wow.. The Guru himself speaks.

I think host name alias is the right approach since each of the sites needs to have its own unique URL.

Addition of Apache Webserver would not be feasible since there might be many customers and you might not want to add a new server for each one.

The only tricky party which appears diffcult to manage is ..

"The server should be smart enough to look at the url, use the WAR for some things, and look at a customised copy of things like css and images for another."

So I looked for a few links which might be of use to you ...

http://www.javaworld.com/javaworld/jw-10-2004/jw-1025-xkins.html

https://sourceforge.net/projects/xkins/

I'm not sure if the above articles would really be very helpful to you but this is the least I can do to a person who has been constantly sharing his knowledge by helping people on this forum.

Regards

Rohit

RohitKumara at 2007-7-15 2:39:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Yes I do occasionally hit trouble myself. In fact more than occasionally. Thats one reason I can answer questions - because I have met most of them myself at one point or another. But this is one time where googling for an answer hasn't helped overmuch.

You have of course hit the most difficult requirement - the bit which I was stuck on as well. The project manager is adamant that he has seen it done before in Tomcat. I'm thinking there is a part of the puzzle I am missing.

I can see you could work it from within the webapp. Look at the URL (request.getURL()) and from that determine which css/images directory to refer to.

eg with www.mysite1.com and www.mysite2.com you could have /css/mysite1.css or /css/mysite2.css and load the appropriate one for the requested URL.

However the logic there is in the webapp, not the server.

Is there a way to do it with the just the server?

evnafetsa at 2007-7-15 2:39:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

I think one Apache server might be required based on your scenario for setting up the virtual host [which u already pointed out ;-) ] along with Tomcat.

Have a look into the settings in the following thread :-

http://marc2.theaimsgroup.com/?l=tomcat-user&m=115704190523619&w=1

NameVirtualHost *:80

<VirtualHost *:80>

ServerName www.myserver.com

DocumentRoot "F:/Tomcat5.5/webapps/ROOT"

Alias /webappA/ F:/Tomcat5.5/webapps/webappA

Alias /webappB/ F:/Tomcat5.5/webapps/webappB

JkMount /servlet/* worker1

JkMount /*.jsp worker1

</VirtualHost>

You might need to research by pointing to the respective images folder in the Apache httpd.conf with respect to virtual host settings :-

Alias /webappA/ F:/Tomcat5.5/webapps/imagesA

Alias /webappB/ F:/Tomcat5.5/webapps/imagesB

Also play around with Jkmount & JkUnmount

Cant say if this is the correct solution, but actual simulation might only validate this requirement. I'm adding this topic to my watch list. Please do email me [rohitk2000@gmail.com] in case you solve this ..cos I'm too curious to learn such an interesting topic.

I hope someone who has already worked on a similar scenario would be able to suggest better.

Regards

Rohit

RohitKumara at 2007-7-15 2:39:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...