Filter, Air Filter
Author: Zen tower wangyue (http://www.cnblogs.com/yaoyinglong) filter to do thing Request Filter response Filter
Note that the sequence dependency of the filter cannot be hardcoded into the program. It should be controlled by DD.
The filter is similar to Servlet 1. The Container knows the API of the filter.
After a common Java class implements the Filter interface, this Java will change dramatically and become a exactly J2EE Filter. 2. lifecycle of the Container Management Filter
Similar to Servlet filters, the init and destory methods are available. Corresponding to the Servlet doGet/doPost method, the filter has a doFilter method. 3 are declared in DD
A Web application may have multiple filters. A given request may cause multiple filters to be executed. You can declare the filters to be run for requests and the order in DD.
Filter Lifecycle
Three methods in the Filter interface that each Filter must implement: init, doFilter, and destory.
Declare and determine the filter order
Configure the filter in DD:
REQUEST: Enable the filter for client requests.
INDLUDE indicates that the filter is enabled for requests dispatched by an include () call.
RORWARD indicates that the filter is enabled for requests dispatched by a forward () call.
ERROR indicates that the filter is enabled for the resources called by the ERROR processor. Rules for determining the filter order:
1. First, find all the filters that match the URL pattern.
2. Combine all matched filters into a chain in the Order stated in DD.