Filter, Air Filter

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.