• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpServletResponse Output Stream

 
Abhishek Rath
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Can I retrieve the HttpServletResponse output to a file in hard disk using JAVA filter.
 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me see if I understand the problem.

You want, whatever is sent to the client as HTML output, to be saved to a file. Right?

If so, then yes, filters can do that. In the doFilter method, you create an HttpServletResponseWrapper. A quick example:
The TeeOutputStream is similar, but it has no backing writer of itself so you'll need to redirect each call to both output streams:
 
Abhishek Rath
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public PrintWriter format(String format, Object... args)
{
super.format(format, args);
writer.format(format, args);
return this;
}

public PrintWriter format(Locale locale, String format, Object... args)
{
super.format(locale, format, args);
writer.format(locale, format, args);
return this;
}


the format method is no defined.it is not getting compiled.
 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you're not using Java 5.0 or up, and you can remove those methods completely.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic