GeeCON Prague 2014*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes filter mapping 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 "filter mapping" Watch "filter mapping" New topic
Author

filter mapping

Manju Devarla
Ranch Hand

Joined: Dec 14, 2006
Posts: 85
Hi,
Can any one explain me about this..

Which of the statements is true about the following deployment descriptor snippet?

<filter-mapping>
<filter-name>Filter1</filter-name>
<servlet-name>ServletToFilter</servlet-name></filter-mapping><filter-mapping>

<filter-name>Filter2</filter-name>
<url-pattern>/*</url-pattern></filter-mapping>

How come the answer for the above question is " Filter2 will be invoked before Filter1 if ServletToFilter is requested"

Becuase filters are invoked the order in which they apper in DD right..
so it should be Filter..
Grace Yang
Ranch Hand

Joined: Apr 01, 2007
Posts: 58
The rule of filter chain is to loop through URL pattern matching first, it invokes the one matches; then the servlet matching.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Becuase filters are invoked the order in which they apper in DD right..

Nope. As Grace pointed out, URL matching takes priority before Name matching.


[My Blog]
All roads lead to JavaRanch
Anupama Ponnapalli
Ranch Hand

Joined: Jun 12, 2006
Posts: 66
Satou is right.

Filter Chaining Rules:

1. All filters with matching URL patterns are located. They are executed in the order of declaration in the DD.
2. After this, all the filters with the matching servlet-name in the DD are located and executed in the order of declaration.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: filter mapping