File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Filtering Responses Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Filtering Responses" Watch "Filtering Responses" New topic

Filtering Responses

Johnnie Smith

Joined: May 02, 2012
Posts: 23
I have a question regarding filtering of responses using wrappers.

I have noted in JSP books that whenever the class HttpServletResponseWrapper is extended by a programmer's own wrapper class, the programmer has to provide definition for both the getWriter() method as well as getOutputStream() method.

Is it required to provide definition for both methods? If so, can somebody tell met the reason as in my case I have provided definition for only the getWriter() method and my filter works fine.

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102

That's interesting. Because Oracle's example also only overrides getWriter().

I've only needed to do this a few times and I didn't override both either. I'm guessing the reason is that a servlet could call getOutputStream() and would miss the new logic. Which does imply it is a good idea. But I haven't been burned not doing it either.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Filtering Responses
It's not a secret anymore!