Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dispatcher for Filter Mapping

Tags:

java

jsp

I have an app written for Servlet Spec 2.4 with an old webserver designed for Servlet Spec 2.3. The web.xml file has the following syntax:

<filter-mapping> 
    <filter-name>sitemesh</filter-name>  
    <url-pattern>*.action</url-pattern>   
    <dispatcher>REQUEST</dispatcher>    
    <dispatcher>FORWARD</dispatcher> 
</filter-mapping> 

How can I re-write this mapping to be servlet 2.3 compliant?

like image 450
George Avatar asked Jun 03 '10 18:06

George


People also ask

What is dispatcher in filter?

The dispatcher type of a request is used by the container to select the filters that need to be applied to the request: Only filters with matching dispatcher type and url patterns will be applied. The initial dispatcher type of a request is defined as DispatcherType. REQUEST.

What is filter mapping?

A filter mapping matches a filter to a web component by name, or to web resources by URL pattern. The filters are invoked in the order in which filter mappings appear in the filter mapping list of a WAR.

What is filter mapping in web xml?

The filter-mapping element maps a URL pattern or servlet name to an instance of a filter. The filter-mapping always contains a filter-name element and a url-pattern element. The filter-name element must match a filter-name defined in a filter element elsewhere in the web. xml file.

What is a request dispatcher?

public interface RequestDispatcher. Defines an object that receives requests from the client and sends them to any resource (such as a servlet, HTML file, or JSP file) on the server.


1 Answers

You can just remove the <dispatcher> entries. The Servlet 2.3 filter by default dispatches on everything and that's just okay. Sitemesh even mentions at its own site that it's compatible with Servlet 2.3. Here's an extract from their site:

SiteMesh is a Servlet Filter and therefore requires a container that conforms to the Servlet 2.3 specification.

like image 185
BalusC Avatar answered Sep 18 '22 16:09

BalusC