Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Filter sequence question in Head first book

 
thomas jacob
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question: What will be the filter sequence for the below request path
<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>

Answers with path as given in the book:
1)/Recipes/HopsReport.do .......Filter1, Filter5
2)/Recipes/HopsList.do..........Filter1,5,2
3)/Recipes/Modify/ModRecipes.do..Filetr1,5,4
4)/HopList.do...................Filter5
5)/Recipes/Add/AddRecipes.do....Filter1,3,5

My doubts
why is the filter sequence in 2)Filter1,5,2 and not 1,2,5?
why is the filter sequence in 3)Filter1,5,4 and not 1,4,5?

Doesn't the matched paths execute in the filter sequence mention in the DD?
 
Rohan Kayan
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Filter Sequence

Firstly - All matching url-patterns in the order they specified in DD
Then - All matching servlet-name in the order they specified in DD
 
Arvind Sampath
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why is the filter sequence in 2)Filter1,5,2 and not 1,2,5?


Thomas,

You are right. The order of execution of filters is 1,2 and 5. I cross checked this by creating and running a sample app in Tomcat 5.1
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic