You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Eddie Fung <ig...@netspace.net.au> on 2002/11/21 07:28:21 UTC

Forwarding and File Download problem

This is an old one but I have scoured the archives and not seen a 
definitive answer to my problem.

I am downloading a file via an Action class and want to refresh the Page 
display after the download completes. Now the action which should be 
forwarded to is not being executed. I have even tried to forward to a JSP 
rather than Action class but nothing seems to work.

This has been reported on more than one occasion eg:
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=struts-user@jakarta.apache.org&msgId=154587

Never found a definitive answer.

Also the dialog box that IE pops up says that "you are downloading the 
file: <action class name>  from localhost". This is misleading as the 
actual dialog box that is next presented correctly names the output file 
name that I have set up. How can I change the name of the file on the first 
dialog box ?


TIA

Eddie


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Forwarding and File Download problem

Posted by Pontus Jonsson <po...@educ.umu.se>.
On tor, 2002-11-21 at 07:28, Eddie Fung wrote:

> 
> Also the dialog box that IE pops up says that "you are downloading the 
> file: <action class name>  from localhost". This is misleading as the 
> actual dialog box that is next presented correctly names the output file 
> name that I have set up. How can I change the name of the file on the first 
> dialog box ?
>

The only way I know of to suggest a filename to a browser is to output
the header

Content-disposition: attachment; filename=<filename>

However I think this only applies when you're dumping the file directly
after the header. Is this what you want to do?

Pontus
-- 
--------------------- p o n t u s  j o n s s o n
Pontus.Jonsson@educ.umu.se          +46907867143
GPG key:   http://www.educ.umu.se/~pontus/gpg.txt
------------------------------------------------

Re: Forwarding and File Download problem

Posted by Mike Way <mi...@sharedskills.com>.
Eddie,

The reference you refer to is for upload, so I am a bit confused as you 
talk about download.

I assume you do mean download so:

To change the name that you are downloading you need to have a mapping to 
your download servlet so that you can use a request path like 
http://....../download/myFile.jpg then the browser dialog will show 
myFile.jpg. I am not sure how you'd acheive this with an Action Class, I'd 
look around creating a new mapping something like this:

   <servlet-mapping>
     <servlet-name>action</servlet-name>
     <url-pattern>/download/*</url-pattern>
   </servlet-mapping>

Before anyone shoots me down, I am not at all sure this will work as it 
stands, but it is a starting point.

As far as the redirection after the download is concerned, you have a 
problem in that the browser is requesting the page and then doing nothing 
else. That's the way HTTP works :-(

You could experiment with using a refresh header tag in the page from which 
you launch the download, so that it refreshes every 5 seconds or so.

Hope the (slightly vague) ideas help.

Mike

At 17:28 21/11/2002 +1100, you wrote:
>This is an old one but I have scoured the archives and not seen a 
>definitive answer to my problem.
>
>I am downloading a file via an Action class and want to refresh the Page 
>display after the download completes. Now the action which should be 
>forwarded to is not being executed. I have even tried to forward to a JSP 
>rather than Action class but nothing seems to work.
>
>This has been reported on more than one occasion eg:
>http://nagoya.apache.org/eyebrowse/ReadMsg?listName=struts-user@jakarta.apache.org&msgId=154587
>
>Never found a definitive answer.
>
>Also the dialog box that IE pops up says that "you are downloading the 
>file: <action class name>  from localhost". This is misleading as the 
>actual dialog box that is next presented correctly names the output file 
>name that I have set up. How can I change the name of the file on the 
>first dialog box ?
>
>
>TIA
>
>Eddie
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>


Mike Way,
Senior Consultant, Shared Skills Ltd
+44 (0)1752 491088, mobile +44 (0) 7941 225581
email: mike.way@sharedskills.com web: www.sharedskills.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>