Two Laptop Bag*
The moose likes Web Component Certification (SCWCD/OCPJWCD) 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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Filters" Watch "Filters" New topic


sangeeta kapoor
Ranch Hand

Joined: Jun 15, 2004
Posts: 70
Page 699 HF Servlets and JSP
Ques 5

Which about Filters is true

A. Filters may be used to create request and response wrappers.
B. Wrappers may be used to create request or reponse filters

Shouldn't B be correct instead of A
Correct Ans given in book is A
Ranch Hand

Joined: Jul 24, 2002
Posts: 379
I also had the same problem the first time, then I understood. Thanks to filter, it's possible to create a 'wrapper' around a request/response objects. Filters use wrappers but it's not the other way round. Think of a filter to compress the response. The filter uses the HttpServletResponseWrapper class to actually pass behind the scenes a custom response object whose getOutputStream() method returns a custom output stream in gzip format. It's the filter which knows about the wrapper and not the other way round.

Hope this helps

Marco Tedone<br />SCJP1.4,SCJP5,SCBCD,SCWCD
wood burning stoves
subject: Filters
Similar Threads
Confusing terminology: Filter and Wrapper
Please answer the following HF question (Page 703) on filters
Doubt in Filters HFSJ
HFS - page 703 Q 5 - ambiguous options
Doubt about HFSJ chapter 13 mock question 5