• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubt on HFSJ Ch 13 mock ques #5.

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I got question 5 on chapter 13 wrong after reading HFJS twice. I wonder why one of the correct answers is A. The statement of choice A is "Filter is used to create request and response wrappers.". Answers at the back of the chapter indicate that explanation can be found on page 51 of servlet specfication. I read that page but did not spot any sentence that states that fact.

Can someone please help me clear my doubt?

Thanks and regards,

Connie Leung
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I came across the same question and wondered the same thing.

Option A: "Filters may be used to create request or response wrappers."
Option B: "Wrappers may be used to create request or response filters."

I picked option B (twice! >_< even though the answer is option A with the explanation "option B is incorrect because the terminology is reversed."

I picked option B because I thought a class that implements the Filter interface (the "request or response filter") uses/instantiates other wrapper classes in the doFilter() method, like the example on page 690. Doesn't that mean wrappers can be "used to create" request or response filters (option B)?

Now I read a few times more, I would choose option A if it means something like "I can use the Filter mechanism to pass wrappers for request/response objects to the servlet", hence filters can be "used to create" request or response wrappers.

Why is my first explanation incorrect?? Or am I just confused on the English here.....
 
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My guess is that we need to be simpler here.

Does not exist neither "request filter objects" nor "response Filter objects".
--> ""Wrappers may be used to create request or response filters.""

Filters can only create another mechanism to "decorate" real request and response objects, improving it before sending back to the client.

So Filters create "decorators objects" (wrapper classes) for doing this.
--> "Filters may be used to create request or response wrappers".

regards,
 
Connie Ky Leung
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for replying.
reply
    Bookmark Topic Watch Topic
  • New Topic