|
Page Edited :
SLINGxSITE :
Filters
Filters has been edited by Mike Mueller (Apr 23, 2009). Content:Servlet Filter SupportSling supports filter processing by applying filter chains to the requests before actually dispatching to the servlet or script for processing. Filters to be used in such filter processing are plain OSGi services for the type javax.servlet.Filter which of course means that the services implement this interface. For Sling to pick up a javax.servlet.Filter service for filter processing two service registration properties are inspected:
Filter ChainsSling maintains two filter chains: the request filter chain and the component filter chain. The filters on the request filter chain are only called once for the complete request processing. The request level filter chain is comparable to the set of filters configured as <dispatcher>REQUEST</dispatcher> in Servlet API 2.5 web applications (see section SRV.6.2.5 Filters and the RequestDispatcher). The filters on the component filter chain are processed for each included resource initiated through the RequestDispatcher. The component level filter chain is comparable to the set of filters configured as <dispatcher>INCLUDE,FORWARD,ERROR</dispatcher> in Servlet API 2.5 web applications (see section SRV.6.2.5 Filters and the RequestDispatcher). Note, that it is currently not possible to call filters only on include, forward, or error or any combination. Filter ProcessingFilter processing is part of the Sling request processing, which may be sketched as follows:
The first step of request processing is the Request Level processing which is concerned with resolving the resource, finding the appropriate servlet and calling into the request level filter chain. The next step is the Component Level processing, calling into the component level filters before finally calling the servlet or script:
When a servlet or script is including another resource for processing through the RequestDispatcher (or any JSP tag or other language feature ultimately using a RequestDispatcher) the following Dispatch processing takes place:
Note, that after ensuring the resource to be included (or forwarded to) and resolving the servlet or script to handle the included (or forwarded) resource, the Component Level processing takes place as for the general request processing. As a consequence, request level filters will be called at most once during request processing (they may not be called at all if a filter earlier in the filter chain decides to terminate the request) while the component level filters may be called multiple times while processing a request. |
Unsubscribe or edit your notifications preferences
