Oracle JavaServer Pages Developer's Guide and Reference
Release 8.1.7

Part Number A83726-01





Go to previous page Go to beginning of chapter Go to next page

Application Root and Doc Root Functionality

This section provides an overview of application roots and doc roots, distinguishing between servlet 2.2 functionality and servlet 2.0 functionality.

Application Roots in Servlet 2.2 Environments

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 /home/dir/mybankappdir/dir1/abc.html:


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 /home/mydefaultdir/dir2/def.html:


OracleJSP Application Root Functionality in Servlet 2.0 Environments

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:

Go to previous page
Go to beginning of chapter
Go to next page
Copyright © 1996-2000, Oracle Corporation.

All Rights Reserved.