iTP Secure WebServer System Administrator's Guide (iTPWebSvr 6.0+)

Using NonStop Servlets for JavaServer Pages
(NSJSP)
iTP Secure WebServer System Administrator’s Guide523346-002
9-28
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.
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 the Web Application on page 9-24, the context is
/myapp1, the name of the application.
Consider the URI 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 URL path is /myapp1. (Together they form the URI.)
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,
/myapplication. 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
There are two parts to the mapping process. 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 which 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.
Here is an example fragment of a web.xml file that maps any URL containing the
application name to a specific servlet.
<servlet-mapping>
<servlet-name>start</servlet-name>
<servlet-class>startCartRequest</servlet-class>
<url-pattern>/myapplication/*</url-pattern>
</servlet-mapping>
Path mappings are relative to the context’s URL path. By providing a wildcard (*) any
URL containing the path /myapplication will now always be passed to the
startCartRequest servlet.