• 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

Problem with HttpServletResponseWrapper

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

I've been stucked with a problem, I'm trying to implement HttpServletResponseWrapper, so I can get a hold of the response outputstream from a filter. I'm just implementing the example from the following webpage: http://download-uk.oracle.com/docs/cd/A97329_03/web.902/a95878/filters.htm#998358 (Example 3 at the bottom), but it doesn't work if my request is a JSP page, the stream that I get from the wrapper is empty, but it does work if it is a outputstream from a Servlet (using getOutputStream()). I'm using Apache Tomcat 5.5. Has anybody had a similar problem? I guess it must be an additional method from HttpServletResponseWrapper that needs to be overriden, I just can't find which one it is.

Thanks!
 
Daniel Del Moral
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been researching around. I override getOutputStream and getWriter in my HttpServletResponseWrapper:



and



This is my implementation of FilterServletOutputStream



I've noticed that JspWriter does calls getWriter from my HttpServletResponseWrapper, so I'm sure that JspWriter has my ServletOutputStream wrapper, the problem is that later, JspWriter doesn't call any of my overriden write methods, so I never get the output from jsp. Any ideas why this could be happening?

Thanks!
 
Daniel Del Moral
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Done!

I just need to flush the PrintWriter that I returned at getWriter method of my HttpServletResponseWrapper. I just had to flush it after the Servlets have donde the writing, I did it after the doFilter on my filter.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic