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

HFSJ filter-sequence doubt

 
Umakanth Godavarthy
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In HFSJ, pg680 for determining filters sequence the answers given seems to be wrong.
<filter-mapping>
<filter-name>Filter1</filter-name>
<url-pattern>/Recipes/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>Filter2</filter-name>
<url-pattern>/Recipes/HopList.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 Path
----------------------------------------------------------------------
/Recipes/HopReport.do
my ans:1,5
HFSJ:1,5
/Recipes/HopList.do
my ans:2,1,5
HFSJ: 1,5,2
/Recipes/Modify/ModRecipes.do
my ans:4,1,5
HFSJ: 1,5,4
/HopList.do
my ans:5
HFSJ: 5
/Recipes/Add/AddRecipes.do
my ans:3,1,5
HFSJ:1,3,5

According to spec SRV.11.1 Mapping Requests to servlets, the order is as follows:
1. exact match
2. longest path prefix
3. extension match
4. default servlet

Please tell me what are the answers
-Thanks
[ December 16, 2005: Message edited by: Umakanth ]
 
Umakanth Godavarthy
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah i got the answers after reading pg54 servlet spec SRV.6
The order the container uses is:
1. the <url-pattern>
2. <servlet-name> matching

But this looks bit contradictory to the original servlet matching rules defined in SRV.11. But ofcourse there are lot of strange things in servlet world !!!
 
MI Mohammed
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Umakanth,
I quite agree with you that there are alot of strange things in
the servlets and JSP world, but there are rules, you must follow.
For your question, the rules are quite easy.

Servlet ==== from specific to wild.(ie in --- out);
Filters ===== from wild to specific.( out ---- in);
ie, the <url-pattern> tags are place on the stack before
<servlet> tags.

All the best.

SCJP SCJA SCWCD
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Umakanth", this is your final warning. We don't have many rules around here, but the Javaranch naming policy is one of them. If you do not comply, your account will be closed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic