File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt about Filter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt about Filter" Watch "Doubt about Filter" New topic
Author

Doubt about Filter

Victor Maehira
Ranch Hand

Joined: Mar 08, 2007
Posts: 33
Good afternoon ranchers!
I was solving a mock then the following statement appeared: "Filters are called in the order they appear in the deployment descriptor". It was considered true. However, if a filter that has a matching <servlet-name> is declared before a filter with a matching URL pattern, the order is inversed! What do you think?!
khushhal yadav
Ranch Hand

Joined: Jun 20, 2007
Posts: 242

Hi Victor,

"Filters are called in the order they appear in the deployment descriptor".


The above statement is perfectly OK
The only thing is that first the container checks for the url-pattern in the order in which they are are defined in the DD.
And then comes the turn of servlet-name.
<url-pattern> gets preference over <servlet-name>.

But the order of execution is determined by the deployment descriptor. That's true.

Regards,
Khushhal


rgrds,
Khushhal
Victor Maehira
Ranch Hand

Joined: Mar 08, 2007
Posts: 33
Hi yadav
I see your point of view. I would say that the statement is partially true! Because it is not the only rule for ordering filter! If a "<servlet-name> filter" is declared before a "<url-pattern> filter", the statement is not true! I know there are more important questions for us to worry about, however we can face similar subtle situations!

[ August 31, 2007: Message edited by: Victor Maehira ]
[ August 31, 2007: Message edited by: Victor Maehira ]
khushhal yadav
Ranch Hand

Joined: Jun 20, 2007
Posts: 242

Sorry Victor

But that's only how it works.
There are no more intricacies in it.
Conainer works like this only

The order the container uses in building the chain of filters to be applied for a particular request URI are as follows:
1.First,the <url-pattern> matching filter mappings in the same order that these elements appear in the deployment descriptor.
2.Next, the <servlet-name> matching filter mappings in the same order that
these elements appear in the deployment descriptor.

Regards,
Khushhal
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt about Filter
 
Similar Threads
Filter sequence question in Head first book
Filter doubt
[Solved][HFSJ] Filter Preferences
filter mapping
Doubt in ordering of filters