As of Servlet 3.0, a filter may be invoked as part of a {@link javax.servlet.DispatcherType.REQUEST REQUEST} or{@link javax.servlet.DispatcherType.ASYNC ASYNC} dispatches that occur inseparate threads. A filter can be configured in {@code web.xml} whether itshould be involved in async dispatches. However, in some cases servlet containers assume different default configuration. Therefore sub-classes can override the method {@link #shouldNotFilterAsyncDispatch()} to declarestatically if they shouuld indeed be invoked, once, during both types of dispatches in order to provide thread initialization, logging, security, and so on. This mechanism complements and does not replace the need to configure a filter in {@code web.xml} with dispatcher types.
Sub-classes may use {@link #isAsyncDispatch(HttpServletRequest)} todetermine when a filter is invoked as part of an async dispatch, and use {@link #isAsyncStarted(HttpServletRequest)} to determine when therequest has been placed in async mode and therefore the current dispatch won't be the last one.
Yet another dispatch type that also occurs in its own thread is {@link javax.servlet.DispatcherType.ERROR ERROR}. Sub-classes can override {@link #shouldNotFilterErrorDispatch()} if they wish to declare staticallyif they should be invoked once during error dispatches.
The {@link #getAlreadyFilteredAttributeName} method determines how toidentify that a request is already filtered. The default implementation is based on the configured name of the concrete filter instance. @author Juergen Hoeller @author Rossen Stoyanchev @since 06.12.2003
|
|