Help coderanch get a
new server
by contributing to the fundraiser
  • 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

Doubt in HFSJ sharpen pencil page 695

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In HFSJ, page 695 , sharpen pencil , it wrote


<filter-mapping>
<filter-name>Filter1</filter-name>
<servlet-name>/Recipes/*</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>Filter2</filter-name>
<servlet-name>/Recipes/HopsList.do</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>Filter3</filter-name>
<servlet-name>/Recipes/Add/*</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>Filter4</filter-name>
<servlet-name>/Recipes/Modify/ModRecipes.do</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>Filter5</filter-name>
<servlet-name>/*</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>Filter5</filter-name>
<servlet-name>/Recipes/*</servlet-name>
</filter-mapping>

with request path a./Recipes/HopsReport.do
b./Recipes/HopsList.do
c./Recipes/Modify/ModRecipes.do
d./HopsList.do
b./Recipes/Add/AddRecipes.do

the answer wrote for chain wrote
a.Filters: 1,5
b.Filters: 1,5,2
c.Filters: 1,5,4
d.Filters: 5
e.Filters: 1,3,5



in my opinion should be...
a.Filters: 1,5
b.Filters: 2,1,5
c.Filters: 4,1,5
d.Filters: 5
e.Filters: 3,1,5

the different si just at url that match 3 url
how to chain more then 3 url that match, its look not the same rule as DD url pattern (url winner)?




Joko
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have book on hand. The element you typed is wrong. Please check.

<servlet-name>/Recipes/*</servlet-name>
should be <url-pattern>/Recipes/*</url-pattern>

The answer is based on the sequence of the filter mapping: match URL pattern first, and then servlet name.
 
joko mujoko
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right Cai Dong Shan,

the book write <url-pattern> not <servlet-name>, but so Still sam question , how is the chain if the filter above change from <url-pattern> to <servlet-name> for the a,b,c,d url ?

Joko
 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

I am also having the same doubt...
please clarify...


Regards,
Hari Krishna.
 
Cai DongShan
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We take b./Recipes/HopsList.do for example

1. Match URL pattern with the sequence of the filter list, only two are found, filter1 and then filter5.
"/*" means all the servlets under application root and its subdirectories

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

2. Match servlet name with the sequence of the filter list, only one is found, filter2.

<filter-mapping>
<filter-name>Filter2</filter-name>
<servlet-name>/Recipes/HopsList.do</servlet-name>
</filter-mapping>

So the answer is 1,5,2

Does it clear your query?
 
joko mujoko
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Cai DongShan...

Thats clear enought,The conclusion is, the rule no.

1. Match URL pattern with the sequence of the filter list, only two are found, filter1 and then filter5.
"/*" means all the servlets under application root and its subdirectories


and the chain of this following the rule of winner like in Deployment Descriptor


2. Match servlet name with the sequence of the filter list, only one is found, filter2.


its just suposse to match just one Servlet


ones again thanks alot Cai DongShan, its helper


Joko
 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
joko mujoko,

Good that you got this doubt cleared from javaranch community. I see a duplicate post for same question from you, i undertand we all want our answers soon, even i do nothing wrong in that, but it would nice of you if you request and get the one of the topic closed, helps save time for other people who answer.

Thanks,
Reshma
[ June 03, 2006: Message edited by: Reshma Pai ]
 
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic