• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Confusing terminology: Filter and Wrapper

 
warren li
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page 699 of HFSJ book:

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

I think B is correct, but the answer given is A. The explanation given is "terminology reversed"!

Why do you need filters to create wrappers?
but you do use wrappers inside filters to send the wrapped Response to the next Filter or the servlet resource.

Where am I wrong here? Much help is appreciated.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a fine linguistical point, I guess.

You can't use wrappers to create filters - you'd use them to help implement filters.
 
Bryan Basham
author
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Warren,

The idea behind this mock item is that you need to create a filter before you can wrap the request/response objects. You said it yourself: "but you do use wrappers inside filters to send the wrapped Response to the next Filter or the servlet resource."

On the other hand you cannot create a filter just be using a wrapper around the request/response objects, which you could do inside of a servlet. In other words, creating a wrapper does not imply that you have created a filter.

Does that help?

-Bryan
 
warren li
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's clear to me now. Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic