Re: Filter for triggering 'download' dialog..

David Orriss Jr <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
On Thu, Feb 27, 2003 at 10:43:14AM -0800, Dror Matalon wrote:
> We're doing something similar in a filter, though for different reasons.
> You have two ways to do it:
> 1. Quick and dirty. Set the reply buffer size to something large
> and then it won't get flushed.
>

Bad idea, for obvious reasons... ;)


> 2. a. create a wrapper object that extends HttpServletResponseWrapper that
> has its own "out" object.
>    b. do chain.doFilter(request, wrapper)
>          c. Now your data is writen to the wrapper. When the filter gets control
>          back do something like this.
>                  outWriter = response.getWriter();

Don't you mean here wrapper.getWriter()?
                    ^^^^^^^^^^^^^^^^^^^

>                                          //print the string to the servlet's output
>                                          CharArrayWriter caw = new CharArrayWriter();
>                                          caw.write(wrapper.toString());
>
> Jason Hunter has a good article about filters in javaworld. You might
> want to look at it.
>

Thanks for the info.  At least I know what direction to go in.

--

 David Orriss Jr.

___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.