You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Isaac Arias <ik...@tokenzone.com> on 2001/07/12 05:37:19 UTC

How to map different URLs to the same Context / webapp?

Hi all,

I spent more than a couple of hours searching the mailing list
archives, google, groups.google, etc. and I couldn't find postings
regarding this issue.

I'm trying to map multiple URLs to the same Servlet Context (webapp).
I'm using Tomcat 3.2.2, Apache and mod_jk (ajp13). I thought that I
could do something like:

JkMount /url1/* ajp13
JkMount /url2/* ajp13

and somehow have Tomcat handle both requests with the same servlet
context. I'm doing this because we have implemented a controller
servlet that parses the path and we would like to give this servlet
full control. In other words, we would like to be able to present
different URLs (for branding purposes, client requirements, etc.)
while still handling the whole application from a central servlet.

Once you're inside a particular context, it's very straightforward to
map different URLs (using web.xml mappings) to the same servlet (all
anchored at the same base servlet context), but if you mount two
different URLs on Apache (i.e. with mod_jk) I need to define two
different contexts in Tomcat (even if both context URLs point to the
same webapp directory). I believe wildcards cannot be used in the
server.xml file.

Right now I'm just handling two parallel contexts which seems like a
waste of resources since they both share the same classes, etc. Is
there something in the spec that prevents this from being done? Should
I attempt to do something at the Apache (httpd) level? It's important
the the address shown in the user's browser reflects the two different
URLs.

Any ideas, config file snippets or pointers would be greatly
appreciated.

Sincerely,

Ike
__________________________________________________________

 Isaac Arias
 Tokenzone
__________________________________________________________
   Man will occasionally stumble over the truth, but most
         of the time he will pick himself up and continue.
                                      - Winston Churchill