This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFSJ Page 696 decalring filters in DD

 
Satyajeet Kadam
Ranch Hand
Posts: 224
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which is true about declaring filters in dd?

a)unlike servlets,filters cannot have initialization parameters.

b) Filter chain order is always determined by order the elements appear in dd.

c)A class that extends an API request or reponse wrapper class
must be declared in dd.

d)A class that extends an API request or response wrapper class is
using the Intercepting Filter pattern.

e) Filter chain is afftected by whether filter mappings are
declared via <url-pattern> or via <servlet-name>


Ans) e

But i don't understand why it is not B ?

PLease correct me if i am wrong.

FilerManager creates filter chain by matching requested URI.
It executes filter one by one unitl it reaches target resource. THis
order is determined by the order of the elements appear in DD.

first it locates
1) filters with matching url pattern then
2) it find filter mapping with <servlet-name>
 
Jay Palaniappan
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amol,
The filter mappings can be defined in DD in 2 ways. One by servlet-name another by url-pattern. In below example 3 filters are defined. 2 are based on URL patterns and 1 with servlet name. Even though the servlet-name filter appears first in the DD, when the container builds the Filter Chain it looks at the URL pattern filter definitions first and then look at the servlet-name filter definitions.


<filter>
<filter-name>TestFilter1</filter-name>
<filter-class>com.test.Filter</filter-class>
</filter>

<filter-mapping>
<filter-name>TestFilter1</filter-name>
<servlet-name>TestServlet</servlet-name>
</filter-mapping>

<filter-mapping>
<filter-name>TestFilter1</filter-name>
<url-pattern>/test/filter/*</url-pattern>
</filter-mapping>


<filter-mapping>
<filter-name>TestFilter1</filter-name>
<url-pattern>/test/*</url-pattern>
</filter-mapping>
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic