It actually does say right at the top that it was added in 1.2.6. If
you think that should be expanded upon, feel perfectly free to add to
the page... that's the beauty of a Wiki after all :)
Frank
Anuradha S.Athreya wrote:
Thanks , I got it working with Download Action. But one thing missing in the
tutorial was that there was no mention that this Download Action was
available post struts 1.2.6. Would be great if this is included.
Thanks all.
-----Original Message-----
From: Frank W. Zammetti [mailto:[EMAIL PROTECTED]
Sent: Monday, August 22, 2005 5:16 AM
To: Struts Users Mailing List
Subject: Re: Struts Download Action
That's good info... might be worth adding to the Wiki (hint-hint :) )
Also, I don't think there is anything to stop you from using the
DownloadAction in Struts prior to 1.2.6 when, IIRC, it was added. I
could be wrong, but I don't remember anything that would make that not work.
Frank
Sudhaker Raj wrote:
http://wiki.apache.org/struts/StrutsFileDownload is great, but in case
you are using struts older than 1.2.6...
You just return null from execute method, framework will not do any
thing further. Now it is your responsibility to read the target file,
set correct content-type and then write the content on
response.getOutputStream();
Sample code:
public class ResponseWriterAction extends Action {
public ActionForward execute( ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
response.setContentType("application/zip");
// Set the content disposition
// To download
response.setHeader("Content-disposition",
"attachment; filename=" + fileName);
// To open up in the browser
// response.setHeader("Content-disposition",
// "inline; filename=" + fileName);
byte[] buff = new byte[4096]; // 4KB
OutputStream out = response.getOutputStream();
while (moreContent) {
// read content in buff byte[]
out.write(buff);
}
out.close();
return null;
}
}
Hope this helps.
Cheers,
Sudhaker
On 8/21/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hi All,
I'm developing a web application based on Struts. In this, one of the
features to be included is , to download a file, when the user clicks on
the link in the JSP page.
Also, when the user clicks on the link, the Save/Open dialog box should
appear.
If nyone has used the DownloadAction provided by Struts OR any other
solution , please help.
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]