Re: Filter for triggering 'download' dialog..

Dror Matalon <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
On Thu, Feb 27, 2003 at 12:43:05PM -0800, David Orriss Jr wrote:
> 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... ;)

Agreed, but I thought I'd mention it.

>
>
> > 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()?
>                     ^^^^^^^^^^^^^^^^^^^

No.

>
> >                                          //print the string to the servlet's output
> >                                          CharArrayWriter caw = new CharArrayWriter();
> >                                          caw.write(wrapper.toString());
                                                                                                                                                                                                             ^^^^^^^^^^^^^^^^^^

This is where the writer's data gets writen to the response output string.

> >
> > 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
>

--
Dror Matalon
Zapatec Inc
1700 MLK Way
Berkeley, CA 94709
http://www.zapatec.com

___________________________________________________________________________
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.