You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Moynihan, Edward" <EM...@russellmellon.com> on 2004/10/13 19:12:23 UTC
Streaming an attachment from an Action not working with Internet Explorer
Hi,
Can anyone point me in the right direction with the following problem that I am experiencing.
I've written a very simple action that streams back to the client an attachment. So, here is a code snippet from the action to illustrate what I am doing. Assume that the URL to hit the action is /testDownloadAction.do and I am using https instead of http.
response.setContentType("application/octet-stream");
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", "-1");
buf = new StringBuffer();
buf.append("attachment;filename=").append("TextDownloadByOctectStreamWithoutForward.txt");
response.setHeader("Content-Disposition", buf.toString());
writer = response.getWriter();
writer.write("Sending down some text. This is a text download without a forward");
writer.flush();
writer.close();
actionForward = null;
When I use FireFox, I get a FileDownload dialog and I am allowed to save the file of name "TextDownloadByOctectStreamWithoutForward.txt".
However, when I use IE 6.0 the FileDialog pops up and says that the file name is "testDownloadAction.do". If I try to hit Save, IE comes back with an error.
Does anyone have any resources to help me understand why this is not working in IE?
Thanks.
-Ed.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Streaming an attachment from an Action not working with Internet Explorer
Posted by Martin Gainty <mg...@hotmail.com>.
Ed
My experience is that the majority of Microsoft programs (IE) default to
saving contents to %USERPROFILE% folder
I would suggest using fully qualified pathname
%TOMCAT_HOME%\\webapps\\testDownload\\TextDownloadByOctectStreamWithoutForwa
rd.txt
(instead of relative path..)
Anyone else?
Martin-
----- Original Message -----
From: "Susan Bradeen" <sb...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Thursday, October 14, 2004 8:56 AM
Subject: Re: Streaming an attachment from an Action not working with
Internet Explorer
> On Wed, 13 Oct 2004 13:12:23 -0400, Moynihan, Edward
> <em...@russellmellon.com> wrote:
> > Hi,
> > Can anyone point me in the right direction with the following problem
that I am experiencing.
> >
> > I've written a very simple action that streams back to the client an
attachment. So, here is a code snippet from the action to illustrate what I
am doing. Assume that the URL to hit the action is /testDownloadAction.do
and I am using https instead of http.
> >
> > response.setContentType("application/octet-stream");
> > response.setHeader("Pragma", "no-cache");
> > response.setHeader("Expires", "-1");
> >
> > buf = new StringBuffer();
> >
buf.append("attachment;filename=").append("TextDownloadByOctectStreamWithout
Forward.txt");
> > response.setHeader("Content-Disposition", buf.toString());
> >
>
> I don't have reason to believe that StringBuffer is working here, but
> just in case have you tried something like:
>
> response.setHeader("Content-Disposition", "attachment; filename=\"" +
> "TextDownloadByOctectStreamWithoutForward.txt;" + "\"");
>
> or perhaps you are just missing some escaped quotes around your filename?
>
>
> > writer = response.getWriter();
> > writer.write("Sending down some text. This is a text
download without a forward");
> > writer.flush();
> > writer.close();
> >
> > actionForward = null;
> >
> > When I use FireFox, I get a FileDownload dialog and I am allowed to save
the file of name "TextDownloadByOctectStreamWithoutForward.txt".
> > However, when I use IE 6.0 the FileDialog pops up and says that the file
name is "testDownloadAction.do". If I try to hit Save, IE comes back with
an error.
> >
> > Does anyone have any resources to help me understand why this is not
working in IE?
> >
> > Thanks.
> >
> > -Ed.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Streaming an attachment from an Action not working with Internet Explorer
Posted by Susan Bradeen <sb...@gmail.com>.
On Wed, 13 Oct 2004 13:12:23 -0400, Moynihan, Edward
<em...@russellmellon.com> wrote:
> Hi,
> Can anyone point me in the right direction with the following problem that I am experiencing.
>
> I've written a very simple action that streams back to the client an attachment. So, here is a code snippet from the action to illustrate what I am doing. Assume that the URL to hit the action is /testDownloadAction.do and I am using https instead of http.
>
> response.setContentType("application/octet-stream");
> response.setHeader("Pragma", "no-cache");
> response.setHeader("Expires", "-1");
>
> buf = new StringBuffer();
> buf.append("attachment;filename=").append("TextDownloadByOctectStreamWithoutForward.txt");
> response.setHeader("Content-Disposition", buf.toString());
>
I don't have reason to believe that StringBuffer is working here, but
just in case have you tried something like:
response.setHeader("Content-Disposition", "attachment; filename=\"" +
"TextDownloadByOctectStreamWithoutForward.txt;" + "\"");
or perhaps you are just missing some escaped quotes around your filename?
> writer = response.getWriter();
> writer.write("Sending down some text. This is a text download without a forward");
> writer.flush();
> writer.close();
>
> actionForward = null;
>
> When I use FireFox, I get a FileDownload dialog and I am allowed to save the file of name "TextDownloadByOctectStreamWithoutForward.txt".
> However, when I use IE 6.0 the FileDialog pops up and says that the file name is "testDownloadAction.do". If I try to hit Save, IE comes back with an error.
>
> Does anyone have any resources to help me understand why this is not working in IE?
>
> Thanks.
>
> -Ed.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org