Oracle Logo

Servlet 4.0 Mapping Discovery Sample Application

 


Servlet 4.0 Mapping Discovery Introduction

Every mapping that causes a Servlet to be activated, regardless of whether or not Servlet Filters are involved, is discoverable at runtime via the Servlet Mapping API. This feature allows runtime discovery of the manner in which the HttpServlet for the current HttpServletRequest was invoked. Invoking any of the methods must not block the caller.

The method getHttpServletMapping() on HttpServletRequest returns an HttpServletMapping implementation that provides information for the mapping that caused the current Servlet to be invoked.

As with the included and forwarded request parameters, the HttpServletMapping is not available for servlets that have been obtained with a call to ServletContext.getNamedDispatcher().

Description of the Example

This example demonstrates how to use Servlet Mapping API at runtime.

This example has two Servlets, ServletA and ServletB. The following hyperlinks explore the various values for the properties of HttpServletMapping, depending which Servlet is invoked and with what path.

Use This Example