tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Raghupathy, Gurumoorthy" <>
Subject RE: Dynamic URIs Using one Context
Date Wed, 16 May 2007 08:53:41 GMT
You can use and  ( User Web App
) in conjunction with a mod_rewrite and proxy ...... Not simple but
achievable .... :)


-----Original Message-----
From: Johnny Kewl [] 
Sent: 16 May 2007 08:43
To: Tomcat Users List
Subject: Re: Dynamic URIs Using one Context

Interesting question....  this is wot I would do.... try!
The basic thing I would use Apache Httpd for it to.... direct via
hosting and the worker file... domain names to various tomcat instances.
eg you can have 2 tomcat instances on a machine and tomcat spread across

many machines.

So domain names become things like Games.ServiceProvider.Net 
Accounts.ServiceProvider.Net   Webs.ServiceProvider.Net 

..... Context paths as far as I am concerned dont work... nor do I (you)

really want them....
It works on the web-app name and the uri mapping in web.xml.... or the 
web-app name and the path to the jsp..... forget about context paths.
It makes more sense outside of context paths, anyway...

So if a client writes an app    the uri will be


In theory you can mess with the relative URI.... but in practice you
For example if you just change the webappname of the WAR... you will see

that uri also changes... and tomcat does the right thing with the
paths (automatically!).
If you change the path to a jsp.... it will change the uri.
If you change the servlet mapping in web.xml you can put the servlet 
anywhere..... eg 
etc etc....

BUT..... if you mess with this and even if you wanted to and could
the context paths..... it will probably break the web-app 8 out of 10
because programmers often hardcode paths inside their apps.... or have
relative contexts that they expect to be there.

Point is.... if you forget about the users name in the uri.... life gets

easy... you will be dropping web-apps into a tomcat web-app... and going
a coffee break.
Sometimes 2 users will have the same web app name.... you dont change 
it..... thats why you got multiple tomcat instances.
Sometimes the user will want the root of the domain.... and his own
name.... that requires a restart of the system.... because you going to
apache to map that 2  the TomcatsInstancesWithOwnDomainNames.... and
tomcat will Map via the hosts section to that users own webapp
ie if a user wants a domain name... they get their very own tomcat
location)... and they can use ROOT.... ie they own that domain.
Own domain name users will need a restart... so you try isolate that 
system... own domain users pay more..... but they got their own tomcat.

Keeping track of users..... spreadsheets.... ie webappx belongs to userx
Domainer's.... a good question now will be.... can the tomcat manager be

used to install web-app remotely.... only in one <host docbase> section
not the others..... if so its great.... once setup... own domainers...
their own thing.

Other thing is if a user... an own domainer... ever wanted load 
balancing.... its easy to provide....

If you want to get it to what you suggesting.... just tell the users
their webapp name must be their username.... thing is, I think you will
thats the last thing most people want in thier uri.....     ..... yuk!

Something like that..... nice interesting project..... have fun....

----- Original Message ----- 
From: "Nathan Hook" <>
To: <>
Sent: Tuesday, May 15, 2007 8:28 PM
Subject: Dynamic URIs Using one Context

> We've been given a difficult problem to solve and I'm hoping that some

> help/insight is available on this mailing list.
> We are an Application Service Provider (ASP) that has numerous clients

> with the number of clients increasing rapidly.  All our clients use
> same application but each client needs/wants a distinguishing element
> the url to identify them to their users.
> Here is our current setup:
> Apache 2.2 with mod_jk sending requests to Tomcat 5.5.  Struts 1.3.8
> our current web framework.
> In our httpd.conf we have a different domain name for each client:
> <VirtualHost *:80>
>    ServerName <client name 1>.<server name>.com
>    DocumentRoot <some directory>/<client name 1>.<server name>.com
> </VirtualHost>
> <VirtualHost *:80>
>    ServerName <client name 2>.<server name>.com
>    DocumentRoot <some directory>/<client name 2>.<server name>.com
> </VirtualHost>
> Then in our server.xml config file for Tomcat we only declare one Host

> element with a Context that has many Alias':
> <Host name="<client name 1>.<server name>.com" appBase="webapps">
>    <Context path="/app" >
>    </Context>
>    <Alias><client name 2>.<server name>.com</Alias>
>    <Alias><client name 3>.<server name>.com</Alias>
>    ...etc for each of our clients...
> </Host>
> So, what is the problem?  Well, when we add a new customer we have to
> the httpd.conf, the server.xml, restart both applications, and add the
> <customer>.<server name>.com to DNS (Usually, we have to wait until
> into the evening to do these tasks).  Our Client Services team want
> ability to add customers without having to wait until we can restart
> servers.
> Is it possible to do the following with an Apache 2.2 and Tomcat 5.5 
> combination while having only ONE instance of the application only
> loaded in Tomcat?  (Meaning we do NOT want the application loaded by 
> Tomcat x times, with x being the number of clients we have.)
> <base name>.<server name>.com/<client name 1>/app
> <base name>.<server name>.com/<client name 2>/app
> <base name>.<server name>.com/<client name 3>/app
> I'm not really the best with how the Context attribute works outside
> having it placed in the server.xml.  I've tried reading the
> on Contexts at:
> But, I find what is explained a tad bit confusing.
> Here is one thread from the archives that explained our problem pretty

> well, but there never really was an answer on how to accomplish the
> except "you're getting the right behavior with a 400 response":
> Finally, through some other research, it seems as though someone was 
> trying to use mod_vhost_alias to accomplish the same thing.
> Any thoughts or suggestions are welcome.
> Thank you for your time.
> _________________________________________________________________
> Make every IM count. Download Messenger and join the i'm Initiative
> It's free.
> ---------------------------------------------------------------------
> To start a new topic, e-mail:
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message