This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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