• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Pno-:695 HFS&JSP Filter Sequence

 
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<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
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks
i got it
 
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is a age old question
filters with url-pattern are executed before serlvets
 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Story like this gets better after being told a few times. Or maybe it's just a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic