GeeCON Prague 2014*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Filter are not Wrappers! ... or are they? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Filter are not Wrappers! ... or are they?" Watch "Filter are not Wrappers! ... or are they?" New topic
Author

Filter are not Wrappers! ... or are they?

Keith Flo
Ranch Hand

Joined: Nov 29, 2005
Posts: 128

I'm a little confused by the answer to a mock exam question in the K&B book on page 735 question 5.

The question is ...
"Filters may be used to create request or response wrappers?" ... I would think this is false since the API provides classes like HttpServletRequestWrapper etc. ... that 'wrap' (aka .. 'decorator' pattern) Servlet requests and responses. Of course one can write their ones own implementation of the ServletRequest and ServletResponse interfaces. Yet in either case theses wrappers are not Filters! And implementations of the Filter interface are not wrappers!

Am I missing something here? .. or .. Is the book incorrect?


kf
SCJP 5.0 (preparing for SCWCD)
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

It's true that Filters are not Wrappers (the title of your post).

But the question doesn't ask whether Filters are Wrappers. Read it again. It asks whether Filters can create Wrappers. You point to examples of Wrappers as evidence that Filters are not Wrappers. Well, that's correct but it wasn't the question. Could a Filter create one of those Wrappers? Of course it could.
Keith Flo
Ranch Hand

Joined: Nov 29, 2005
Posts: 128

Paul,

Could a Filter create one of those Wrappers? Of course it could.


The difference seems so subtle ... as to be nearly impossible to distinguish a difference .... however, I 'll keep this in mind as i prepare for the test. I'd like to get even this kind of question right!
 
GeeCON Prague 2014
 
subject: Filter are not Wrappers! ... or are they?