File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Filters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Filters" Watch "Filters" New topic
Author

Filters

Sondra Colagrossi
Ranch Hand

Joined: Oct 30, 2002
Posts: 68
I been shopping in the pet store and I'm confused about how the FilterChain gets setup.
The following element is from the 2.3 DTD.
<!ELEMENT filter-mapping (filter-name, (url-pattern | servlet-name))>
So if I have the following in my deployment descriptor:
<filter-mapping>
<filter-name> filter_1 </filter-name>
<servlet-name> myServlet </servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name> filter_2 </filter-name>
<servlet-name> myServlet </servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name> filter_3 </filter-name>
<servlet-name> myServlet </servlet-name>
</filter-mapping>
I can expect the container to setup the FilterChain of filter_1, filter_2, filter_3.
The FilterChain.doFilter( req, res ) is a call from filter to filter?
[ December 17, 2002: Message edited by: Bob Fred ]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Bob,
Your assumption is correct: the container will setup the filter chaining for you.
However, you will need to indicate (in your filter code) when this chaining occurs. This is where you will have to call the chain.doFilter (request, response) method.
Cheers
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Filters
 
Similar Threads
role-link and role-name elements?
How to specific numerous url-patterns in web.xml
role-link and role-name elements?
servlet-name
Q: Filter on Page 668 and page 695