In the first few chapters of the book it is explained that
the response object that is passed into the servlet is also
used to write the output to client. But in the Filters chapter
it seems the response object that is passed into chain.doFilter()
is not used to write the output, instead a new response object
is used. I mean, two different response objects are used before and
after the call to chain.doFilter().
I like to make it clear whether this is the actual scenario?
The main purpose of the response object is to send some data to the client.
Filters are used to do some pre or post processing on request and response objects.(There are few other usages where we can use filters).
Filter.doFilter will accept request and response objects as you know.
Assume one scenario which is given in HFSJ book. If you want to do something to the request object before it handed to servlet(or jsp), take that object and wrap it and send the wrapper request to the servlet(or jsp).
Same as the case of Response. I fyou want to add some headers or edit some thing on response object, before it send it to the client . Use wrapper of Response object.
Remember that Filter.doFilter will accpet any kind of request and response objects.
SCJP 5.0(84%), SCWCD 5.0(97%), SCDJWS 5.0(98%)
I knew I would regret that burrito. But this tiny ad has never caused regrets:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database