jQuery in Action, 2nd edition*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HFSJ Page 696 decalring filters in DD 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 "HFSJ Page 696 decalring filters in DD" Watch "HFSJ Page 696 decalring filters in DD" New topic
Author

HFSJ Page 696 decalring filters in DD

Satyajeet Kadam
Ranch Hand

Joined: Oct 19, 2006
Posts: 215
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

Joined: Jul 10, 2008
Posts: 3
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
 
subject: HFSJ Page 696 decalring filters in DD