NonStop Servlets for JSP System Administrator's Guide

Configuring NSJSP
NonStop Servlets for JavaServer Pages (NSJSP) System Administrator’s Guide—525644-001
3-15
Map Requests to Applications and Servlets
Map Requests to Applications and Servlets
Mapping requests to servlets is closely linked to the concepts of a context path.
The application name and the context path gets you to the application subdirectory. No
further path is necessary to find a servlet or JSP within that application. The
deployment descriptor XML (web.xml) file defines the rest of the path.
The location of the application directory (and therefore the servlet or JSP) is
determined in the docBase attribute inside iTP_server.xml.
The servlet or JSP could be any name (given the <servlet-name> and <servlet-
class> XML elements of the web.xml file) not just the class name. Using these
elements allows separation between the web pages (using a servlet name) and the
underlying Java code (using the class name) and so makes maintenance easier.
The servlet or JSP does not even need a name, given the <servlet-mapping> XML
element of the web.xml file. You can set the mapping so that one servlet or JSP is
always the start of the application and, accordingly, does not need to be named in the
URL. Mapping is certainly convenient, and it might also be more secure.
URL Mapping to the Application
In a web container, each application is associated with a context and all resources
exist relative to that context. The context path starts at the root level of the application
directory. In our Configuring Web Applications on page 3-10, the context is /myapp1,
the name of the application.
Consider the URL that locates that context:
http://www.hostname.com/myapp1
The http://www.hostname.com is a URL for the HTTP scheme located at
www.hostname.com. The URI path is /myapp1. Together they form the URL.
As well as the www.hostname.com notation shown above, URLs can take the form
http://hostname:portnumber/myapp1
Each web application must be mapped to a unique URL path prefix, for instance,
/myapp1. The web container uses this prefix to map requests to resources within the
web application. The path name therefore serves as the document root for serving
resources within the application.
URL Mapping to the Servlet
The mapping process has two parts. The first part is to provide servlet name and,
optionally, an alias for the full servlet class name. Thus we could have a servlet name
such as start that refers to the servlet class startCartRequest.
The second part, again optional, is to use the <servlet-mapping> elements of the
deployment descriptor. This would be used to provide a more complex mapping than
the usual inclusion of servlet name (or class name) in the URL.