Two Laptop Bag
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Order of Filter Execution Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Order of Filter Execution" Watch "Order of Filter Execution" New topic

Order of Filter Execution

Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344

In what order are thr filter invoked for the following browser request?

a. FilterOne, FilterThree
b. FilterOne, FilterTwo, FilterThree
c. FilterThree, FilterTwo
d. Filterhree, FilterTwo
e. FilterThree
f. None

What will be the order of filter execution for the above coding?

I think it will be:

as like servlt-mapping...whether it is applicable to filter-mapping too.

Micheal John
SCJP 1.4 (86%), SCWCD 1.4 (86%), SCBCD 1.3 (85%), SCDJWS (Just Started...) - Satisfaction Lies in Our EFFORT, Not in the ATTAINMENT
Manish Agarwal

Joined: Jan 30, 2006
Posts: 20
Hi Michael,

Filter executes in the order they are defined in the DD.
see this link

SCWCD1.4, SCJP1.4, OCA 9i
Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
what will be the output?
Stella Kim

Joined: Jan 18, 2007
Posts: 25
I think the order is :
FilterOne --> FilterThree --> FilterFour

Kim<br />SCJP 1.4 (98%)<br />SCWCD (92%)
Srikanth Raghavan
Ranch Hand

Joined: Oct 31, 2005
Posts: 389
Yes, I too think it's FilterOne --> FilterThree --> FilterFour.

Does that mean the answer is "f. None"?
Elan Ram
Ranch Hand

Joined: Dec 14, 2006
Posts: 40
Hi all,

Resolving Filter is slightly different than Servlet. While application deployment, container has to form the chain based on the filters mapping to the resources in the deployment declaration.

So Container forms the first set chain based on the url mappings (<url-pattern> then exact mapping (<servlet-name> with the second set. Order of application is first chain and then second chain.

Thanks and regards,
Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
Anyone confirm the answer?
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Filters will be executed in order they are defined in the deployment descriptor and requested URL lies in the range of defined URL Mapping.

In your case the answer will be option f because the order of execution will be FilterOne,FilterThree,FilterFour.
I agree. Here's the link:
subject: Order of Filter Execution
It's not a secret anymore!