aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt in HFSJ sharpen pencil page 695 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt in HFSJ sharpen pencil page 695" Watch "Doubt in HFSJ sharpen pencil page 695" New topic
Author

Doubt in HFSJ sharpen pencil page 695

joko mujoko
Ranch Hand

Joined: May 30, 2006
Posts: 30
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
Cai DongShan
Ranch Hand

Joined: Dec 07, 2004
Posts: 102
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.


Best Regards,<br />DongShan<br /> <br />SCJP1.4, SCWCD1.4
joko mujoko
Ranch Hand

Joined: May 30, 2006
Posts: 30
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
Krishna Latha Grandhi
Ranch Hand

Joined: Nov 08, 2005
Posts: 110
Hi Friends,

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


Regards,
Hari Krishna.
Cai DongShan
Ranch Hand

Joined: Dec 07, 2004
Posts: 102
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

Joined: May 30, 2006
Posts: 30
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
Reshma Shanbhag
Ranch Hand

Joined: Sep 17, 2002
Posts: 202
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 ]

SCJP 1.4, SCWCD 1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in HFSJ sharpen pencil page 695