How does the web container compute filesystem resource paths corresonding to alternate docroots?

When configuring an alternate docroot, keep in mind the following rules:

  • Alternate docroots (more specifically, their <code>from</code> values) are matched against a request's path info (obtained by calling <code>javax.servlet.http.HttpServletRequest.getPathInfo()</code>).
  • The local path of a resource whose request has been matched by an alternate docroot is computed by appending the request's path info to the alternate docroot's <code>dir</code> value.

As an example, consider the following alternate docroot declaration in <code>sun-web.xml</code>:

<property name=''alternatedocroot_1'' value=''from=/orderstore/* dir=C:/stryker_cci/orderstore''/>

and this request URL:

http://localhost/CIWeb/orderstore/test.txt

Assume the request is mapped to a web application deployed at <code>/CIWeb</code>, meaning the request URL's context root component is given as <code>/CIWeb</code>, and its path info component is given as <code>/orderstore/test.txt</code>, which is matched by
the above alternate docroot. The local filesystem path where the requested resource will be looked up is given as the value of the alternate docroot's <code>dir</code> value:

C:/stryker_cci/orderstore

with the request's path info:

/orderstore/test.txt

appended to it, resulting in:

C:/stryker_cci/orderstore/orderstore/test.txt

As another example, consider the following alternate docroot declaration in <code>sun-web.xml</code>:

<property name=''alternatedocroot_1'' value=''from=/myimages/* dir=/images''/>

and this request URL:

http://localhost:8080/myimages/image1.jpg

Further assume that the above request is mapped to a web application deployed at the root context (<code>/</code>). In this case, the request's path info evaluates to:

/myimages/image1.jpg

meaning it is matched by the above alternate docroot. The local filesystem path where the requested resource will be looked up is
given as the value of the alternate docroot's <code>dir</code> value:

/images

with the request's path info:

/myimages/image1.jpg

appended to it, resulting in:

/images/myimages/image1.jpg