tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markus Schönhaber <>
Subject Re: Overlapping contexts?
Date Mon, 23 Jan 2006 11:35:21 GMT
Chris Mooring wrote:
> I was just wondering if it is possible to have "overlapping contexts"? I am
> not sure if this will make sense so I'll try and explain it with a little
> example;
> Basically, I'd like to be able to have two *similar* URL's map to separate
> locations on the filesystem;
> Example;
> localhost/myapp/index.jsp (refers to C:\myapp\index.jsp)
> localhost/myapp/external/index.jsp (refers to Z:\otherapp\index.jsp)
> Ideally, I'd like to achieve this using Tomcat's
> <Context path="/myapp" docBase="C:/myapp"
> ... >
> <Context path="/myapp/external" docBase="Z:/otherapp/"
> ... >
> element in server.xml. The important part here is that both contexts begin
> with /myapp!
> However, the last time I tried this, I had several different errors when
> Tomcat started up. I believe this may be due to the fact that with Tomcat
> 5.5 and above you shouldn't have context tags in server.xml. Therefore, I
> tried similar things in conf/context.xml with much similar results
> (errors). I then tried separate context files in
> C:\tomcat5\work\Catalina\localhost but this didn't work either.

If you store your <Context> information in individual files in
("conf", not "work"), the path-Attribute is ignored and the path information 
is derived from the name of the XML-file. So if you want to define a 
<Context> which shall be accessible via
the XML-file has to be named "myapp.xml".
If the <Context>'s path shall contain slashes, replace them with "#" in the 
file name.
I don't know if this works but what you could try is the following:
put the two <Context>s you mention above each in an individual XML-file under
and name the first "myapp.xml" and the second "myapp#external.xml".


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message