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

Using NonStop Servlets for JavaServer Pages With
The iTP Secure WebServer
iTP Secure WebServer System Administrator’s Guide—522659-001
9-26
Mapping Requests to Applications and Servlets
<web-app>
<mime-mapping>
<extension>doc</extension>
<mime-type>application/msword</mime-type>
</mime-mapping>
</web-app>
Mapping 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 Application Directory Structure on page 9-23 the context is
/myapplication, the name of the application.
Consider the URI that locates that context:
http://www.company.com/myapplication
The http://www.company.com is a URL for the http scheme located at
www.company.com. The URL path is /myapplication. (Together they form the URI.)
As well as the www.hostname.com notation shown above, URLs can take the form
http://<hostname>:<portnumber>/myapplication
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>