The meaning of filter chain.dofilter (request,response)

Source: Internet
Author: User

The life cycle of a filter typically passes through the following three stages:

Initialization

The init () method is called when the container loads the filter for the first time. The class contains a reference to the Filter Config object in this method. Our filters do not actually need to do this because the initialization information is not used, and this is only for demonstration purposes.

Filter:

Most of the time the filter is consumed here. The Dofilter method is called by the container, passing in a reference to the servlet request, Servlet Response, and Filter Chain objects that are pointed to in the requests/response chain respectively. The filter then has the opportunity to process the request, pass the processing task to the next resource in the chain (by calling the Dofilter method on the Filter Chain object reference), and then handle the response when processing control returns the filter.

Destruction:

The container immediately calls the Destroy () method before garbage collection, so that any necessary cleanup code can be executed.

About Chain.dofilter (request,response)
His role is to forward the request to the next object on the filter chain. The next one here is the next filter, if there is no filter that is the resource you requested. General filter is a chain, Web. XML is configured with several. and one by one.

Request resource, Filter2->filter3---Filter1

The meaning of filter chain.dofilter (request,response)

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.