Oracle Blog

Blog for jluehe

Alternate Docroots and Local Resource Paths

Alternate Docroots and Local Resource Paths

Judging from the traffic on the various GlassFish mailing lists and user forums, it seems that support for alternate docroots in GlassFish has become very popular.

However, from the feedback given, it looks like the way alternate docroot paths are computed by the web container deserves additional coverage: Several developers have tried leveraging alternate docroots and were left wondering why the container would return a 404 response instead of the contents of the requested resource.

Hopefully, this blog will clarify things.

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

Assume the request is mapped to a web application deployed at /CIWeb, meaning the request URL's context
root component is given as /CIWeb, and its path info component is given as /orderstore/test.txt, 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 "dir" 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 sun-web.xml: