This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Zero to AI - A non-technical, hype-free guide to prospering in the AI era and have Nicolò Valigi and Gianluca Mauro on-line!
See this thread for details.
Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

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

 
Ranch Hand
Posts: 128
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Marshal
Posts: 25940
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 128
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
This will take every ounce of my mental strength! All for a tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic