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 Pno-:695 HFS&JSP Filter Sequence 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 "Pno-:695 HFS&JSP Filter Sequence" Watch "Pno-:695 HFS&JSP Filter Sequence" New topic
Author

Pno-:695 HFS&JSP Filter Sequence

Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
<filter-mapping>
<filter-name>Filter1</filter-name>
<url-pattern>/Recipes/*</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>Filter2</filter-name>
<url-pattern>/Recipes/HopsList.do</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>Filter3</filter-name>
<url-pattern>/Recipes/Add/*</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>Filter4</filter-name>
<url-pattern>/Recipes/Modify/ModRecipes.do</url-pattern>
</filter-mapping>

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

Request PathFilter Sequence
------------ ----------------
/Recipes/HopReport.do---->1,5(ok)
/Recipes/HopsList.do---->1,5,2(why not 1,2,5 )
/Recipes/Modify/ModRecipes.do---->1,5,4(why not 1,4,5 )
/HopsList.do---->5(ok)
/Recipes/Add/AddRecipes.do---->1,3,5(ok)

Filter url matching sequence is determined by sequence in DD.
i.e if two or more url matches then there sequence will be determined by sequence in DD.

I have doubt in Request Path 2nd and Request Path 3rd

For 2nd path the sequence should be 1,2,5 as per DD sequence
Same way For 3rd path the sequence should be 1,4,5 as per DD sequence

Thanks
aanal jethalia
Greenhorn

Joined: Nov 16, 2006
Posts: 13
for filter 2 and filter 4 instead of <url-pattern> element there is <servlet-name> element in Head First. Filter chain will have the matching url-patterns first and then the matching servlet-name.
Pallavi Roy
Ranch Hand

Joined: Jun 01, 2006
Posts: 37
Hi,
As mentioned earlier that your question is wrong copied.
Change the options to <servlet-name> <url-pattern>/Recipes/HopsList.do</url-pattern>
and <url-pattern>/Recipes/Modify/ModRecipes.do</url-pattern>.

They rule is the url mentioned is mapped to the <filter-mapping>
a) Group the matching <url-pattern> in the sequence they appear in the DD.
b) Group the matching <servlet-name> in the sequence they appear in the DD.

This rule will determine the filter sequence.


Break the ice - SCJP 1.4,<br />Where There's a will- SCWCD 1.4.<br />Back in action - Websphere Certified Portal 6 Application Developer
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
thanks
i got it
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
this is a age old question
filters with url-pattern are executed before serlvets


SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
Renu Radhika
Ranch Hand

Joined: Oct 21, 2005
Posts: 243
only the order in DD matters is it?I thought its from most matching to the least say if url is like /recipes/ind/chat.do

then if there is an exact match like the one above then that will be selected first followed by /recipes/ind then /recipes then /* can anyone explain?
Pallavi Roy
Ranch Hand

Joined: Jun 01, 2006
Posts: 37
Hi Renuka,
The order you mention is for servlet declaration
<servlet-mapping>
<servlet-name>
<url-pattern>
</servlet-mapping>

where the order goes like 1)Exact match 2)directory match 3)/*.xyz match.

But when it comes to filters this order is not followed.
If you see the book then in the bang section you will find this note.

Best Regards,
Pallavi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pno-:695 HFS&JSP Filter Sequence