About the run order of multiple filter in the Web. XML in Tomcat __web

Source: Internet
Author: User
Tags tomcat
Today, in the project, there is a very strange problem: after processing the request.getparameter (arg0) in a filter, the request will not be forwarded to the next filter (case, the current one only in 2 items).

Before the reason is found, only through the conversion filter execution order to resolve

Tidy up a bit ...

The order in which multiple filters are run:

1. Add the filter-mapping element to the chain in the order it appears in the Web. XML deployment descriptor by including the filter for the Url-pattern that matches the request.
2. Add the filter for the filter-mapping element that contains the servlet-name that matches the request after the filter that matches the URL pattern in the chain.
3. In-line first-out, the last item in the chain is often the originally requested resource.

So:
1. The filter runtime configured in Url-pattern must precede the filter configured in the Servlet-name mode
2. In the filter configured in Url-partern, if there are multiple matches to the current request, it is run in the order in which filter-mapping appears in Web. xml

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.