You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Randall Parker <ra...@nls.net> on 2001/08/05 08:10:46 UTC

TC33b1 Context path behavior: Is this a bug or by design?

I'm seeing two different paths as being accepted for pages in the same war file. I'm wondering 
if the behavior I'm seeing is by design or a bug. 

I installed the struts-documentation.war file in webapps and restarted Tomcat 3.3 b1. As 
expected I was able to access such URLs as:
   http://127.0.0.1:8080/struts-documentation/index.html
and 
   http://127.0.0.1:8080/struts-documentation/api/org/apache/struts/taglib/bean/package-
summary.html#package_description

So the leading /struts-documentation mapped to the corresponding war file.

Then I decided to add to the /conf dir the following:
   apps-struts-documentation.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<webapps>
    <!-- Setting special properties for /examples 
         ( as an example of overriding the defaults )
      -->

   <Context path="/strutsdoc" 
            docBase="webapps/struts-documentation" 
            debug="0" 
	    reloadable="true" > 
              <SimpleRealm filename="conf/users/strutsdoc-users.xml" />
              <LogSetter name="strutsdoc_tc.log" path="logs/strutsdoc.log" />
              <LogSetter name="strutsdoc_servlet_log" 
                         path="logs/servlet_strutsdoc.log" 
			 servletLogger="true"/>
  </Context>

</webapps>

After stopping and restarting Tomcat I was then able (as expected) to access pages using 
the shorter /strutsdoc leading path. For instance:
   http://127.0.0.1:8080/strutsdoc/index.html

However, when I went back and tried the original:
      http://127.0.0.1:8080/struts-documentation/index.html
 that still worked. I even did Refresh and fired up a different brand of browser that hadn't 
previously visited either page to make sure the browser wasn't just loading the older URL from 
cache.

Well, I'd expect that when one defined the Context path in the xml file that that path would 
_replace_ the default path named after the war file. Is that not the case? Is this normal 
behavior or incorrect behavior?





Re: TC33b1 Context path behavior: Is this a bug or by design?

Posted by cm...@yahoo.com.
Hi Randall,

I believe the behavior is correct - you have 2 contexts with the same
docbase ( one defined in a config file, one automatically ). They are
completely independent of each other ( you can look into work and you'll
see one work dir for each ). If you write a simple test servlet, you'll
see the 2 contexts have different ServletContext objects, and behave like
2 separate webapps.

The same thing would happen if you copy or do a (symbolic)link between 2
dirs in /webapps, or you add 2 app-XXX.xml files pointing to the same
docbase.

BTW, thanks for investigating this :-)

Costin



On Sat, 4 Aug 2001, Randall Parker wrote:

> I'm seeing two different paths as being accepted for pages in the same war file. I'm wondering
> if the behavior I'm seeing is by design or a bug.
>
> I installed the struts-documentation.war file in webapps and restarted Tomcat 3.3 b1. As
> expected I was able to access such URLs as:
>    http://127.0.0.1:8080/struts-documentation/index.html
> and
>    http://127.0.0.1:8080/struts-documentation/api/org/apache/struts/taglib/bean/package-
> summary.html#package_description
>
> So the leading /struts-documentation mapped to the corresponding war file.
>
> Then I decided to add to the /conf dir the following:
>    apps-struts-documentation.xml
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <webapps>
>     <!-- Setting special properties for /examples
>          ( as an example of overriding the defaults )
>       -->
>
>    <Context path="/strutsdoc"
>             docBase="webapps/struts-documentation"
>             debug="0"
> 	    reloadable="true" >
>               <SimpleRealm filename="conf/users/strutsdoc-users.xml" />
>               <LogSetter name="strutsdoc_tc.log" path="logs/strutsdoc.log" />
>               <LogSetter name="strutsdoc_servlet_log"
>                          path="logs/servlet_strutsdoc.log"
> 			 servletLogger="true"/>
>   </Context>
>
> </webapps>
>
> After stopping and restarting Tomcat I was then able (as expected) to access pages using
> the shorter /strutsdoc leading path. For instance:
>    http://127.0.0.1:8080/strutsdoc/index.html
>
> However, when I went back and tried the original:
>       http://127.0.0.1:8080/struts-documentation/index.html
>  that still worked. I even did Refresh and fired up a different brand of browser that hadn't
> previously visited either page to make sure the browser wasn't just loading the older URL from
> cache.
>
> Well, I'd expect that when one defined the Context path in the xml file that that path would
> _replace_ the default path named after the war file. Is that not the case? Is this normal
> behavior or incorrect behavior?
>
>
>