• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Order of Filter Execution

 
Micheal John
Ranch Hand
Posts: 344
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


In what order are thr filter invoked for the following browser request?
/admin/index.jsp

Options:
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:
1. EXACT MATCH
2. DIRECTORY MATCH
3. EXTENSION MATCH

as like servlt-mapping...whether it is applicable to filter-mapping too.
 
Manish Agarwal
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael,

Filter executes in the order they are defined in the DD.
see this link
 
Micheal John
Ranch Hand
Posts: 344
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what will be the output?
 
Stella Kim
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the order is :
FilterOne --> FilterThree --> FilterFour
 
Srikanth Raghavan
Ranch Hand
Posts: 389
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I too think it's FilterOne --> FilterThree --> FilterFour.

Does that mean the answer is "f. None"?
 
Elan Ram
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Micheal John
Ranch Hand
Posts: 344
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone confirm the answer?
 
Ali Gohar
Ranch Hand
Posts: 572
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic