News Flash: As of version 2.4, filters can be applied to request dispatchers

Think about it. It’s great that filters can be applied to requests that come directly from the client. But what about resources requested from a forward or include, request dispatch, and/or the error handler? Servlet spec 2.4 to the rescue.

Declaring a filter mapping for request-dispatched web resources

<filter-mapping>
  <filter-name>MonitorFilter</filter-name>
  <url-pattern>*.do</url-pattern>
  <dispatcher>REQUEST</dispatcher>

        - and / or -

  <dispatcher>INCLUDE</dispatcher>

        - and / or -

  <dispatcher>FORWARD</dispatcher>

        - and / or -

  <dispatcher>ERROR</dispatcher>
</filter-mapping>

Declaration Rules

  • The <filter-name> is mandatory.

  • Either the <url-pattern> or <servlet-name> element is mandatory.

  • You can have from 0 to 4 <dispatcher> elements.

  • A REQUEST value activates the filter for client requests. If no <dispatcher> element is present, REQUEST is the default.

  • An INCLUDE value activates the filter for request dispatching from an include() call.

  • A FORWARD value activates the filter for request dispatching from a forward() call.

  • An ERROR value activates the filter for resources called by the error handler.

Request path

Filter Sequence

/Recipes/HopsReport.do

Filters:

/Recipes/HopsList.do

Filters:

/Recipes/Modify/ModRecipes.do

Filters:

/HopsList.do

Filters:

/Recipes/Add/AddRecipes.do

Filters:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset