This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with HttpServletResponseWrapper

 
Daniel Del Moral
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic