aspose 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 OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Filters" Watch "Filters" New topic


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-name> filter_1 </filter-name>
<servlet-name> myServlet </servlet-name>
<filter-name> filter_2 </filter-name>
<servlet-name> myServlet </servlet-name>
<filter-name> filter_3 </filter-name>
<servlet-name> myServlet </servlet-name>
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 ]
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.
Consider Paul's rocket mass heater.
subject: Filters