• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

filter-mapping doubt??

 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I have the following doubt regarding filter-mapping

<filet-mapping>
<filter-name>Filter1</filter-name>
<url-pattern>/Recipes/*</url-pattern>
</filter-mapping>


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


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


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


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

And the Request Path

/Recipes/HopsReport.do - The filter order is 1,5 - Makes sense

/Recipes/HopsList.do - The filter order is 1,5,2 - Confued on this. I'd say 2,1,5

Can anyone comment on the above Please!

<filet-mapping>
<filter-name>Filter1</filter-name>
<url-pattern>/Recipes/*</url-pattern>
</filter-mapping>
 
S Kapoor
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Filter mappings dont work like servlet mappings in that there is no order of preference for matches. The no1 is recipes/* and that is a match. Thats all it cares about. It is earlier in the DD and hence it is earlier in the filter invocation order.
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For /Recipes/HopsList.do it should be Filter1, Filter2 and then Filter5. The filters are chosen in order they are defined in Deployment Descriptor.
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ali,

But in the HFSJ book, it is given as 1,5,2. Is that an errata in the book itself??
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Similarily, for the /Recipes/Modify/ModRecipes.do, the options are given as 1,5,4...shouldn't that be 1,4,5?? Anyone please help me on this!
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have HFSJ so can't say anything about that. You should try to code yourself and check the results
[ February 08, 2007: Message edited by: Ali Gohar ]
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone please confimr my doubt???
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jothi, remember these two rules -

the container sees your filters as a set of two groups -
1. those having a <url-pattern> and
2. those having a <servlet-name>

the filters in group 1 are executed before those in group 2.
in both the groups the order of execution is the order in which they appear in the D.D

if you apply these rules to the HFSJ problem on page 695, the answers
1,5,2 and 1,4,5 are ( for cases 2 and 3 respectively )quite valid.

let me know if this is not sufficient.
niranjan8712@gmail.com
niranjan_8712@yahoo.com

hth
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Niranjan,

Can you please elaborate on this for me. I'm still not getting it. I appreciate your effort!
 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jothi Shankar Kumar Sankararaj:
Hi Ranchers,

I have the following doubt regarding filter-mapping

<filet-mapping>
<filter-name>Filter1</filter-name>
<url-pattern>/Recipes/*</url-pattern>
</filter-mapping>


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


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


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


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

And the Request Path

/Recipes/HopsReport.do - The filter order is 1,5 - Makes sense

/Recipes/HopsList.do - The filter order is 1,5,2 - Confued on this. I'd say 2,1,5

Can anyone comment on the above Please!

<filet-mapping>
<filter-name>Filter1</filter-name>
<url-pattern>/Recipes/*</url-pattern>
</filter-mapping>


 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael,

I really did understand your explanation. So as per what you said, first url-pattern is matched and the filters invoked in the order in which they are configured in the DD. Then it looks for filter-name that matches the url pattern and it invokes them as well in the order in which they are configured in the DD.

Thanks and I got it!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic