Choose at least one answer. A. A filter must extend the HttpFilter class Incorrect B. A filter must implement the Filter interface Correct C. Filters are chained to servlets through the flter tag in the deployment descriptor Correct D. A filter must be mapped to one and only one servlet Incorrect E. A filter may be mapped either to a single servlet or to multiple servlets via a URL pattern Correct
The answers are B, C, and E, but I don't agree with C. I believe the filters are chained to servlets through the "<filter-mapping>", not "<filter>" tag, because <filter> declares a filter, not saying anything about the associated servlet.
Am I being too picky or is the question wrong..? Thanks.
If you really want to be picky (which is good ), filters are chained to other filters, and it is the final filter in the chain which then passes the request to either a servlet (including a JSP) or a static resource. It is the <filter-mapping> tag in the DD which declares a filter to be part of a filter chain for a matching request, and the order of the tags in the DD is synonymous with the order of the filters in the chain.
You're not being too picky, you are correct that option C contains that mistake! Where does the question come from?
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / AmazonAmazon UK )