JBridge

JBridge: Certification Question Of The Day

JBridge Home >> Certification Questions >> Question for Saturday May 24th 2003 Saturday May 24th 2003

Which of the following statements about filters is true? (2 correct answers)



A The order in which filters are processed is dependent on the servlet container.
B Initialisation parameters can be obtained from a FilterConfig, available as a parameter to the filter's init() method.
C A filter can be associated either with a servlet name or a url pattern, but not both.
D Filter mappings must be defined within the web.xml deployment descriptor, before listener definitions which in turn come before servlet definitions.
E There is no way of preventing all filters in a filter chain being processed.
Page down for the answer...











































The Answer

B and D are the correct answers.
Answer A is wrong. Servlet containers are honour bound to process filters in the order in which they appear in the web.xml deployment descriptor, processing those with URL patterns first followed by those tied to specific servlet names.
A filter can be associated both with a servlet name and a URL pattern - in other words, there can be multiple mappings for the same filter. So answer C is false.
Finally, it is absolutely possible to stall the filter chain at any point. Unless there is an explicit call to FilterChain.doFilter(request, response) within a filter, processing of the chain will end. This is in many ways the whole point. A filter controlling log on might only choose to pass on the request if certain security criteria are met.


EMail: dbridgewater@jbridge.co.uk
Phone: +44 (0)1943 877414
Fax: +44 (0)1943 877414
Mail: David Bridgewater, Willow Dene, Bradford Road, Menston, Ilkley, West Yorkshire, LS29 6ED, UK
Copyright © 2003 David Bridgewater. All rights reserved.