Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

filter-mapping order

 
Kram Nart
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone explain (in detail if you can) the answer of this mock exam question on http://j2eeworld.weebly.com? Thanks.


Given these filter mapping declarations:

<filter-mapping>

<filter-name>FilterOne</filter-name>

<url-pattern>/admin/*</url-pattern>

<dispatcher>FORWARD</dispatcher>

</filter-mapping>

<filter-mapping>

<filter-name>FilterTwo</filter-name>

<url-pattern>/users/*</url-pattern>

</filter-mapping>

<filter-mapping>

<filter-name>FilterThree</filter-name>

<url-pattern>/admin/*</url-pattern>

</filter-mapping>

<filter-mapping>

<filter-name>FilterTwo</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

in what order are the filters invoked for the following browser request?

/admin/index.jsp

a FilterOne, FilterThree

b FilterOne, FilterTwo, FilterThree

c FilterThree, FilterTwo

d FilterThree, FilterTwo

e FilterThree

f None of these filters are invoked.

Answer: d
 
Dee Brown
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The url patterns for filter1, filter3, and the second filter2 filter mapping match the request.

However, filter1 uses the "<dispatcher>FORWARD</dispatcher>" element, and will only be invoked on a RequestDispatcher.forward().

So the answer is filter3 and the second filter 2 (i.e. D).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic