aspose file tools*
The moose likes I/O and Streams and the fly likes HttpServletResponse Output Stream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "HttpServletResponse Output Stream" Watch "HttpServletResponse Output Stream" New topic
Author

HttpServletResponse Output Stream

Abhishek Rath
Ranch Hand

Joined: Nov 22, 2007
Posts: 38
Hi

Can I retrieve the HttpServletResponse output to a file in hard disk using JAVA filter.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19719
    
  20

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:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Abhishek Rath
Ranch Hand

Joined: Nov 22, 2007
Posts: 38
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

Joined: Oct 27, 2005
Posts: 19719
    
  20

Then you're not using Java 5.0 or up, and you can remove those methods completely.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpServletResponse Output Stream