|Oracle JavaServer Pages Developer's Guide and Reference
Part Number A83726-01
This section provides an overview of application roots and doc roots, distinguishing between servlet 2.2 functionality and servlet 2.0 functionality.
As mentioned earlier, the servlet 2.2 specification provides for each application to have its own servlet context. Each servlet context is associated with a directory path in the server file system, which is the base path for modules of the application. This is the application root. Each application has its own application root.
This is similar to how a Web server uses a doc root as the root location for HTML pages and other files belonging to a Web application.
For an application in a servlet 2.2 environment, there is a one-to-one mapping between the application root (for servlets and JSP pages) and the doc root (for static files, such as HTML files)--they are essentially the same thing.
Note that a servlet URL has the following general form:
When a servlet context is created, a mapping is specified between the application root and the context path portion of a URL.
For example, consider an application with the application root
/home/dir/mybankappdir, which is mapped to the context path
mybank. Further assume the application includes a servlet whose servlet path is
loginservlet. This servlet can be invoked as follows:
(The application root directory name itself is not visible to the end-user.)
To continue this example for an HTML page in this application, the following URL points to the file
For each servlet environment there is also a default servlet context. For this context, the context path is simply "/", which is mapped to the default servlet context application root. For example, assume the application root for the default context is
/home/mydefaultdir, and a servlet with the servlet path
myservlet uses the default context. Its URL would be as in the following example. (Again, the application root directory name itself is not visible to the user.)
(The default context is also used if there is no match for the context path specified in a URL.)
Continuing this example for an HTML file, the following URL points to the file
Apache/JServ and other servlet 2.0 environments have no concept of application roots, because there is only a single application environment. The Web server doc root is effectively the application root.
For Apache, the doc root is typically some
.../htdocs directory. In addition, it is possible to specify "virtual" doc roots through
alias settings in the
httpd.conf configuration file.
In a servlet 2.0 environment, OracleJSP offers the following functionality regarding doc roots and application roots:
globals.jsamechanism, you can designate a directory under the doc root to serve as an application root for any given application. This is accomplished by placing a
globals.jsafile as a marker in the desired directory. (See "Overview of globals.jsa Functionality".)