This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
i'm not able to understand the part from the hfsj book where the ordering of filters is explained. for reference the page no. is 710. following is an excerpt which i couldnt understand
IMPORTANT: The Container’s rules for ordering filters:
When more than one filter is mapped to a given resource, the Container uses the following rules:
1) ALL filters with matching URL patterns are located first. This is NOT the same as the URL mapping rules the Container uses to choose the “winner” when a client makes a request for a resource, because ALL filters that match will be placed in the chain!! Filters with matching URL patterns are placed in the chain in the order in which they are declared in the DD.
2) Once all filters with matching URLs are placed in the chain, the Container does the same thing with filters that have a matching <servlet-name> in the DD.
specifically i couldnt understand the 2nd point. please explain it with a simple example ?
Let's explain it with an example where we have a Servlet (e.g. FilterServlet) with the following mapping:
We can now attach filters on the basis of the url-pattern, for example: http://localhost:8080/WebAppRoot/filter/*, or we can attach a filter on the Servlet name (FilterServlet). If we have the following filters defined in our web.xml: