• 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

HFSJ filter-sequence doubt

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !!!
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Good night. Drive safely. Here's a tiny ad for the road:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic