This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
1. All filters with matching url patterns are located first.Filters with matching url patterns are placed in the chain in the order in which they are declared in the DD.
2. Once the filters with the matching url patterns are placed in the chain, the container does the same thing with the filters that have a matching <servlet-name> in the DD.
FilterTwo invokes after invocation of FilterThree.
If we don't mention <dispatcher> element in <filter-mapping>, or mention it as empty like then it defaults to REQUEST.
Suppose if we send request to the container like, , then container selects the appropriate filters by seeing its <url-parttern> and <dispatcher> element. Here first it sees the 'FilterOne' url-pattern(/admin/*), this is ok, and it sees its <dispatcher> entry, here it is 'FORWARD', it skip this step and moves to the next ones, 'FilterThree' and 'FilterTwo', they satisfy the rules. Finally, it makes a mapping that first I(container) should call 'FilterThree' and after I should call 'FilterTwo'.
then before forwarding to the resource that was present in 'admin' directory, first it checks the <filter-mapping>'s <dispatcher> declaration, like is there is 'FORWARD' present in it? Here it is present. Then it calls the 'FilterOne's doFilter() method and if our doFilter() contains then the resource will be forward to the 'result.jsp'.