Downloading file rendered in JSP
Hi, I'm trying to make one of my pages downloadable as a CSV file. Currently my XML is configured like this: action name=downloadCSV class=test.struts.ListItems method=downloadCSV interceptor-ref name=standardStack/ result name=success/pages/download.jsp/result /action And /pages/download.jsp renders the list as a CSV. I have changed the content type in the CSV: %@ page contentType=text/csv % But I'd like to force the contentDisposition so that I can control the filename. I know it's easy to do that using StreamResult, but that doesn't look like the right solution for me, since I don't want to access a file on the file system and return it, but rather offer a page rendered by that JSP as downloadable. Is there any way to do this, or a way to use StreamResult and configure it so that it can work with a page rendered by a JSP? Thanks D. CONFIDENTIALITY - This email and any files transmitted with it, are confidential, may be legally privileged and are intended solely for the use of the individual or entity to whom they are addressed. If this has come to you in error, you must not copy, distribute, disclose or use any of the information it contains. Please notify the sender immediately and delete them from your system. SECURITY - Please be aware that communication by email, by its very nature, is not 100% secure and by communicating with Perform Group by email you consent to us monitoring and reading any such correspondence. VIRUSES - Although this email message has been scanned for the presence of computer viruses, the sender accepts no liability for any damage sustained as a result of a computer virus and it is the recipients responsibility to ensure that email is virus free. AUTHORITY - Any views or opinions expressed in this email are solely those of the sender and do not necessarily represent those of Perform Group. COPYRIGHT - Copyright of this email and any attachments belongs to Perform Group, Companies House Registration number 6324278.
RE: Downloading file rendered in JSP
To set the download file name, in addition to the text/csv mime type (which you already have set), write the following java code in your Action or (if necessary) as Java in your JSP: response.setHeader(Content-disposition, attachment; filename= + CSV_FILE_NAME); where CSV_FILE_NAME is the name you want the user to see for the csv file. Since this is a dynamically generated file, if you're using https and need to work in IE you may also want to set the following: response.setHeader(Cache-Control, max-age=0); response.setHeader(Pragma, public); see the following two links for more details: http://eirikhoem.wordpress.com/2007/06/15/generated-pdfs-over-https-with -internet-explorer/ http://forum.java.sun.com/thread.jspa?threadID=233446forumID=45 Brad Cupit Louisiana State University - UIS -Original Message- From: David Loup [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 08, 2008 7:42 AM To: user@struts.apache.org Subject: Downloading file rendered in JSP Hi, I'm trying to make one of my pages downloadable as a CSV file. Currently my XML is configured like this: action name=downloadCSV class=test.struts.ListItems method=downloadCSV interceptor-ref name=standardStack/ result name=success/pages/download.jsp/result /action And /pages/download.jsp renders the list as a CSV. I have changed the content type in the CSV: %@ page contentType=text/csv % But I'd like to force the contentDisposition so that I can control the filename. I know it's easy to do that using StreamResult, but that doesn't look like the right solution for me, since I don't want to access a file on the file system and return it, but rather offer a page rendered by that JSP as downloadable. Is there any way to do this, or a way to use StreamResult and configure it so that it can work with a page rendered by a JSP? Thanks D. CONFIDENTIALITY - This email and any files transmitted with it, are confidential, may be legally privileged and are intended solely for the use of the individual or entity to whom they are addressed. If this has come to you in error, you must not copy, distribute, disclose or use any of the information it contains. Please notify the sender immediately and delete them from your system. SECURITY - Please be aware that communication by email, by its very nature, is not 100% secure and by communicating with Perform Group by email you consent to us monitoring and reading any such correspondence. VIRUSES - Although this email message has been scanned for the presence of computer viruses, the sender accepts no liability for any damage sustained as a result of a computer virus and it is the recipient's responsibility to ensure that email is virus free. AUTHORITY - Any views or opinions expressed in this email are solely those of the sender and do not necessarily represent those of Perform Group. COPYRIGHT - Copyright of this email and any attachments belongs to Perform Group, Companies House Registration number 6324278. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Downloading file rendered in JSP
Thanks for that. I actually just needed to implement the ServletResponseAware interface to access the servlet response properly. Trying to set those in the JSP (through a scriplet) didn't work, but indeed doing it in the action is fine. -Original Message- From: Brad A Cupit [mailto:[EMAIL PROTECTED] Sent: 08 April 2008 14:25 To: Struts Users Mailing List Subject: RE: Downloading file rendered in JSP To set the download file name, in addition to the text/csv mime type (which you already have set), write the following java code in your Action or (if necessary) as Java in your JSP: response.setHeader(Content-disposition, attachment; filename= + CSV_FILE_NAME); where CSV_FILE_NAME is the name you want the user to see for the csv file. Since this is a dynamically generated file, if you're using https and need to work in IE you may also want to set the following: response.setHeader(Cache-Control, max-age=0); response.setHeader(Pragma, public); see the following two links for more details: http://eirikhoem.wordpress.com/2007/06/15/generated-pdfs-over-https-with -internet-explorer/ http://forum.java.sun.com/thread.jspa?threadID=233446forumID=45 Brad Cupit Louisiana State University - UIS -Original Message- From: David Loup [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 08, 2008 7:42 AM To: user@struts.apache.org Subject: Downloading file rendered in JSP Hi, I'm trying to make one of my pages downloadable as a CSV file. Currently my XML is configured like this: action name=downloadCSV class=test.struts.ListItems method=downloadCSV interceptor-ref name=standardStack/ result name=success/pages/download.jsp/result /action And /pages/download.jsp renders the list as a CSV. I have changed the content type in the CSV: %@ page contentType=text/csv % But I'd like to force the contentDisposition so that I can control the filename. I know it's easy to do that using StreamResult, but that doesn't look like the right solution for me, since I don't want to access a file on the file system and return it, but rather offer a page rendered by that JSP as downloadable. Is there any way to do this, or a way to use StreamResult and configure it so that it can work with a page rendered by a JSP? Thanks D. CONFIDENTIALITY - This email and any files transmitted with it, are confidential, may be legally privileged and are intended solely for the use of the individual or entity to whom they are addressed. If this has come to you in error, you must not copy, distribute, disclose or use any of the information it contains. Please notify the sender immediately and delete them from your system. SECURITY - Please be aware that communication by email, by its very nature, is not 100% secure and by communicating with Perform Group by email you consent to us monitoring and reading any such correspondence. VIRUSES - Although this email message has been scanned for the presence of computer viruses, the sender accepts no liability for any damage sustained as a result of a computer virus and it is the recipient's responsibility to ensure that email is virus free. AUTHORITY - Any views or opinions expressed in this email are solely those of the sender and do not necessarily represent those of Perform Group. COPYRIGHT - Copyright of this email and any attachments belongs to Perform Group, Companies House Registration number 6324278. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] CONFIDENTIALITY - This email and any files transmitted with it, are confidential, may be legally privileged and are intended solely for the use of the individual or entity to whom they are addressed. If this has come to you in error, you must not copy, distribute, disclose or use any of the information it contains. Please notify the sender immediately and delete them from your system. SECURITY - Please be aware that communication by email, by its very nature, is not 100% secure and by communicating with Perform Group by email you consent to us monitoring and reading any such correspondence. VIRUSES - Although this email message has been scanned for the presence of computer viruses, the sender accepts no liability for any damage sustained as a result of a computer virus and it is the recipients responsibility to ensure that email is virus free. AUTHORITY - Any views or opinions expressed in this email are solely those of the sender and do not necessarily represent those of Perform Group. COPYRIGHT - Copyright of this email and any attachments belongs to Perform Group, Companies House Registration number 6324278. - To unsubscribe, e-mail: [EMAIL PROTECTED
RE: Downloading file rendered in JSP
whoops! I should have been more clear about it using the HttpServletResponse Brad Cupit Louisiana State University - UIS e-mail: [EMAIL PROTECTED] office: 225.578.4774 -Original Message- From: David Loup [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 08, 2008 10:57 AM To: Struts Users Mailing List Subject: RE: Downloading file rendered in JSP Thanks for that. I actually just needed to implement the ServletResponseAware interface to access the servlet response properly. Trying to set those in the JSP (through a scriplet) didn't work, but indeed doing it in the action is fine. -Original Message- From: Brad A Cupit [mailto:[EMAIL PROTECTED] Sent: 08 April 2008 14:25 To: Struts Users Mailing List Subject: RE: Downloading file rendered in JSP To set the download file name, in addition to the text/csv mime type (which you already have set), write the following java code in your Action or (if necessary) as Java in your JSP: response.setHeader(Content-disposition, attachment; filename= + CSV_FILE_NAME); where CSV_FILE_NAME is the name you want the user to see for the csv file. Since this is a dynamically generated file, if you're using https and need to work in IE you may also want to set the following: response.setHeader(Cache-Control, max-age=0); response.setHeader(Pragma, public); see the following two links for more details: http://eirikhoem.wordpress.com/2007/06/15/generated-pdfs-over-https-with -internet-explorer/ http://forum.java.sun.com/thread.jspa?threadID=233446forumID=45 Brad Cupit Louisiana State University - UIS -Original Message- From: David Loup [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 08, 2008 7:42 AM To: user@struts.apache.org Subject: Downloading file rendered in JSP Hi, I'm trying to make one of my pages downloadable as a CSV file. Currently my XML is configured like this: action name=downloadCSV class=test.struts.ListItems method=downloadCSV interceptor-ref name=standardStack/ result name=success/pages/download.jsp/result /action And /pages/download.jsp renders the list as a CSV. I have changed the content type in the CSV: %@ page contentType=text/csv % But I'd like to force the contentDisposition so that I can control the filename. I know it's easy to do that using StreamResult, but that doesn't look like the right solution for me, since I don't want to access a file on the file system and return it, but rather offer a page rendered by that JSP as downloadable. Is there any way to do this, or a way to use StreamResult and configure it so that it can work with a page rendered by a JSP? Thanks D. CONFIDENTIALITY - This email and any files transmitted with it, are confidential, may be legally privileged and are intended solely for the use of the individual or entity to whom they are addressed. If this has come to you in error, you must not copy, distribute, disclose or use any of the information it contains. Please notify the sender immediately and delete them from your system. SECURITY - Please be aware that communication by email, by its very nature, is not 100% secure and by communicating with Perform Group by email you consent to us monitoring and reading any such correspondence. VIRUSES - Although this email message has been scanned for the presence of computer viruses, the sender accepts no liability for any damage sustained as a result of a computer virus and it is the recipient's responsibility to ensure that email is virus free. AUTHORITY - Any views or opinions expressed in this email are solely those of the sender and do not necessarily represent those of Perform Group. COPYRIGHT - Copyright of this email and any attachments belongs to Perform Group, Companies House Registration number 6324278. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] CONFIDENTIALITY - This email and any files transmitted with it, are confidential, may be legally privileged and are intended solely for the use of the individual or entity to whom they are addressed. If this has come to you in error, you must not copy, distribute, disclose or use any of the information it contains. Please notify the sender immediately and delete them from your system. SECURITY - Please be aware that communication by email, by its very nature, is not 100% secure and by communicating with Perform Group by email you consent to us monitoring and reading any such correspondence. VIRUSES - Although this email message has been scanned for the presence of computer viruses, the sender accepts no liability for any damage sustained as a result of a computer virus and it is the recipient's responsibility to ensure that email is virus free. AUTHORITY - Any views or opinions expressed
Downloading file
Hi All, I am developing an application in struts in which I needed to download a file from a server. When iam clicking on download button, file lose its extension and it with the action ie .do and does not open with the associated application. Any help is highly appreciated. Thanks in advance. Thanks and Regards, Balwinder Kumar - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Downloading file
You must use content-disposition header : response.setHeader(Content-Disposition, attachment; filename=\+myfilename+\); You can also add a mime type with something like String mimeType = getServletContext().getMimeType(myfilename); response.setHeader(Content-Type, mimeType==null?x-type/unknown:mimeType); Mike Balwinder a écrit : Hi All, I am developing an application in struts in which I needed to download a file from a server. When iam clicking on download button, file lose its extension and it with the action ie .do and does not open with the associated application. Any help is highly appreciated. Thanks in advance. Thanks and Regards, Balwinder Kumar - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Mike Baroukh --- Cardiweb - 31 Rue de Mogador Paris IXeme 06 63 57 27 22 - 01 53 21 82 63 - Jabber: [EMAIL PROTECTED] http://www.cardiweb.com --- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Downloading file
On 11/3/06, Balwinder [EMAIL PROTECTED] wrote: Hi All, I am developing an application in struts in which I needed to download a file from a server. When iam clicking on download button, file lose its extension and it with the action ie .do and does not open with the associated application. Any help is highly appreciated. Should be a case of setting the content type and disposition properly: For example, for a pdf file: response.setContentType(application/pdf); Then, if you want it to open in the browser, with assoc application: response.setHeader(Content-disposition, inline; filename= + fileName); If you want to save it to disk response.setHeader(Content-disposition, attachment; filename= + fileName); From memory I also had to play with the headers that say don't cache Niall Thanks in advance. Thanks and Regards, Balwinder Kumar - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Downloading file
On 11/3/06, Balwinder [EMAIL PROTECTED] wrote: Hi All, I am developing an application in struts in which I needed to download a file from a server. When iam clicking on download button, file lose its extension and it with the action ie .do and does not open with the associated application. Any help is highly appreciated. You need to do something like this. response.setHeader (Content-Disposition, attachment;filename=foo.pdf); where foo.pdf is the file name you want to be displayed to the user.Imassuming since the file is being served you are correctly setting the the content type of your response. Thanks in advance. Thanks and Regards, Balwinder Kumar - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Puneet
Re: Downloading file
Mike Baroukh wrote: You must use content-disposition header : response.setHeader(Content-Disposition, attachment; filename=\+myfilename+\); You can also add a mime type with something like String mimeType = getServletContext().getMimeType(myfilename); response.setHeader(Content-Type, mimeType==null?x-type/unknown:mimeType); Mike Balwinder a écrit : Hi All, I am developing an application in struts in which I needed to download a file from a server. When iam clicking on download button, file lose its extension and it with the action ie .do and does not open with the associated application. Any help is highly appreciated. Thanks in advance. Thanks and Regards, Balwinder Kumar - 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] Thanks a lot!!Iam through this problem, it is working now. Thanks and Regards, Balwinder Kumar - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem downloading file
Hi¡ I already know that this problem have been resolved before, but i can't find the solution searching in this post. (Or solutions founded don't help me). I have an action that generates pdf files, and zip them. And i want to download it... but i have two problems: -- File that appears in dialog is Action'sNameA.do, no MyFile.zip code is like this - if (gz.exists()) { response.setContentType(application/zip); response.setHeader(Content-Disposition,attachment; fichero=\ + nombreBaseFichero + \;); response.setContentLength((int)gz.length()); ServletOutputStream sos; sos = response.getOutputStream(); FileInputStream stream = new FileInputStream(gz); BufferedInputStream bis = new BufferedInputStream(stream); InputStream is = new BufferedInputStream(bis); int count; byte buf[] = new byte[4096]; while ((count = is.read(buf)) -1) sos.write(buf, 0, count); is.close(); sos.close(); } - --- Dialog appears two times, and next any action i take, download's dialog appears. I read that action must return null but iit doesn't work. Can you help me, please??? Thanks in advance.
Re: Problem downloading file
What do you mean by dialog? Do you want to download this file to display it? Or do you want to download it to keep? The return null for the ActionForward is used to display resources and is called after the response is committed. The call is part and parcel of the content of the response. Jack On Tue, 23 Nov 2004 16:47:21 +0100, moralesdefrías moralesdefrías wrote: Hi¡ I already know that this problem have been resolved before, but i can't find the solution searching in this post. (Or solutions founded don't help me). I have an action that generates pdf files, and zip them. And i want to download it... but i have two problems: -- File that appears in dialog is Action'sNameA.do, no MyFile.zip code is like this - if (gz.exists()) { response.setContentType(application/zip); response.setHeader(Content-Disposition,attachment; fichero=\ + nombreBaseFichero + \;); response.setContentLength((int)gz.length()); ServletOutputStream sos; sos = response.getOutputStream(); FileInputStream stream = new FileInputStream(gz); BufferedInputStream bis = new BufferedInputStream(stream); InputStream is = new BufferedInputStream(bis); int count; byte buf[] = new byte[4096]; while ((count = is.read(buf)) -1) sos.write(buf, 0, count); is.close(); sos.close(); } - --- Dialog appears two times, and next any action i take, download's dialog appears. I read that action must return null but iit doesn't work. Can you help me, please??? Thanks in advance. -- You can't wake a person who is pretending to be asleep. ~Native Proverb~ Each man is good in His sight. It is not necessary for eagles to be crows. ~Hunkesni (Sitting Bull), Hunkpapa Sioux~ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem downloading file
I have the same problem trying to do the same as Morales... To overcome this, i've made a JSP (just because i was too lazy to write a Servlet :) where I get the OutputStream from the response, set the content type and content-disposintion: response.setContentType(application/octet-stream); response.setHeader(Content-Disposition, attachment; filename= + exportedFile().getName() + ;); then I output the content of the file. Works perfectly in the browser, but in log i get: org.apache.jasper.JasperException: getOutputStream called (probably just as warning). I suppose that if I'll put a servlet instead of the JSP, it won't throw this anymore. Regards. Morales de Frías wrote: Hi¡ I already know that this problem have been resolved before, but i can't find the solution searching in this post. (Or solutions founded don't help me). I have an action that generates pdf files, and zip them. And i want to download it... but i have two problems: -- File that appears in dialog is Action'sNameA.do, no MyFile.zip code is like this - if (gz.exists()) { response.setContentType(application/zip); response.setHeader(Content-Disposition,attachment; fichero=\ + nombreBaseFichero + \;); response.setContentLength((int)gz.length()); ServletOutputStream sos; sos = response.getOutputStream(); FileInputStream stream = new FileInputStream(gz); BufferedInputStream bis = new BufferedInputStream(stream); InputStream is = new BufferedInputStream(bis); int count; byte buf[] = new byte[4096]; while ((count = is.read(buf)) -1) sos.write(buf, 0, count); is.close(); sos.close(); } - --- Dialog appears two times, and next any action i take, download's dialog appears. I read that action must return null but iit doesn't work. Can you help me, please??? Thanks in advance. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem downloading file
When you do this, Radu, how does the file show up in the client? Is it downloaded to a directory the client user chooses or is it displayed in the client browser? Thanks. Jack On Tue, 23 Nov 2004 20:24:59 +0200, Radu Badita [EMAIL PROTECTED] wrote: I have the same problem trying to do the same as Morales... To overcome this, i've made a JSP (just because i was too lazy to write a Servlet :) where I get the OutputStream from the response, set the content type and content-disposintion: response.setContentType(application/octet-stream); response.setHeader(Content-Disposition, attachment; filename= + exportedFile().getName() + ;); then I output the content of the file. Works perfectly in the browser, but in log i get: org.apache.jasper.JasperException: getOutputStream called (probably just as warning). I suppose that if I'll put a servlet instead of the JSP, it won't throw this anymore. Regards. Morales de Frías wrote: Hi¡ I already know that this problem have been resolved before, but i can't find the solution searching in this post. (Or solutions founded don't help me). I have an action that generates pdf files, and zip them. And i want to download it... but i have two problems: -- File that appears in dialog is Action'sNameA.do, no MyFile.zip code is like this - if (gz.exists()) { response.setContentType(application/zip); response.setHeader(Content-Disposition,attachment; fichero=\ + nombreBaseFichero + \;); response.setContentLength((int)gz.length()); ServletOutputStream sos; sos = response.getOutputStream(); FileInputStream stream = new FileInputStream(gz); BufferedInputStream bis = new BufferedInputStream(stream); InputStream is = new BufferedInputStream(bis); int count; byte buf[] = new byte[4096]; while ((count = is.read(buf)) -1) sos.write(buf, 0, count); is.close(); sos.close(); } - --- Dialog appears two times, and next any action i take, download's dialog appears. I read that action must return null but iit doesn't work. Can you help me, please??? Thanks in advance. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- You can't wake a person who is pretending to be asleep. ~Native Proverb~ Each man is good in His sight. It is not necessary for eagles to be crows. ~Hunkesni (Sitting Bull), Hunkpapa Sioux~ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem downloading file
Weber, you're the best. Thanks a million. Jack P.S. Would you like a gmail invite? On Tue, 23 Nov 2004 13:31:54 -0500, Erik Weber [EMAIL PROTECTED] wrote: Morales de Frías wrote: Hi¡ I already know that this problem have been resolved before, but i can't find the solution searching in this post. (Or solutions founded don't help me). I have an action that generates pdf files, and zip them. And i want to download it... but i have two problems: -- File that appears in dialog is Action'sNameA.do, no MyFile.zip Probably you already saw this, but if not it might help: http://www.mail-archive.com/user@struts.apache.org/msg10189.html code is like this - if (gz.exists()) { response.setContentType(application/zip); response.setHeader(Content-Disposition,attachment; fichero=\ + nombreBaseFichero + \;); response.setContentLength((int)gz.length()); ServletOutputStream sos; sos = response.getOutputStream(); FileInputStream stream = new FileInputStream(gz); BufferedInputStream bis = new BufferedInputStream(stream); InputStream is = new BufferedInputStream(bis); int count; byte buf[] = new byte[4096]; while ((count = is.read(buf)) -1) sos.write(buf, 0, count); is.close(); sos.close(); } - --- Dialog appears two times, and next any action i take, download's dialog appears. I read that action must return null but iit doesn't work. Can you help me, please??? Thanks in advance. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- You can't wake a person who is pretending to be asleep. ~Native Proverb~ Each man is good in His sight. It is not necessary for eagles to be crows. ~Hunkesni (Sitting Bull), Hunkpapa Sioux~ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem downloading file
Dakota Jack wrote: Weber, you're the best. Thanks a million. Jack You're quite welcome. P.S. Would you like a gmail invite? Why, thank you. But, I already have a gmail account. Unfortunately, my main email address long has been posted all over the Web (I didn't know any better), so what the hell, I might as well keep using it. Earthlink's spam filtering is getting better and better anyway. :-) Erik On Tue, 23 Nov 2004 13:31:54 -0500, Erik Weber [EMAIL PROTECTED] wrote: Morales de Frías wrote: Hi¡ I already know that this problem have been resolved before, but i can't find the solution searching in this post. (Or solutions founded don't help me). I have an action that generates pdf files, and zip them. And i want to download it... but i have two problems: -- File that appears in dialog is Action'sNameA.do, no MyFile.zip Probably you already saw this, but if not it might help: http://www.mail-archive.com/user@struts.apache.org/msg10189.html code is like this - if (gz.exists()) { response.setContentType(application/zip); response.setHeader(Content-Disposition,attachment; fichero=\ + nombreBaseFichero + \;); response.setContentLength((int)gz.length()); ServletOutputStream sos; sos = response.getOutputStream(); FileInputStream stream = new FileInputStream(gz); BufferedInputStream bis = new BufferedInputStream(stream); InputStream is = new BufferedInputStream(bis); int count; byte buf[] = new byte[4096]; while ((count = is.read(buf)) -1) sos.write(buf, 0, count); is.close(); sos.close(); } - --- Dialog appears two times, and next any action i take, download's dialog appears. I read that action must return null but iit doesn't work. Can you help me, please??? Thanks in advance. - 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]
Re: Problem downloading file
Here is a good article related to the problem: http://www.javaworld.com/javatips/jw-javatip94_p.html Lee On Tue, 23 Nov 2004 18:38:30 -0500, Erik Weber [EMAIL PROTECTED] wrote: Dakota Jack wrote: Weber, you're the best. Thanks a million. Jack You're quite welcome. P.S. Would you like a gmail invite? Why, thank you. But, I already have a gmail account. Unfortunately, my main email address long has been posted all over the Web (I didn't know any better), so what the hell, I might as well keep using it. Earthlink's spam filtering is getting better and better anyway. :-) Erik On Tue, 23 Nov 2004 13:31:54 -0500, Erik Weber [EMAIL PROTECTED] wrote: Morales de Frías wrote: Hi¡ I already know that this problem have been resolved before, but i can't find the solution searching in this post. (Or solutions founded don't help me). I have an action that generates pdf files, and zip them. And i want to download it... but i have two problems: -- File that appears in dialog is Action'sNameA.do, no MyFile.zip Probably you already saw this, but if not it might help: http://www.mail-archive.com/user@struts.apache.org/msg10189.html code is like this - if (gz.exists()) { response.setContentType(application/zip); response.setHeader(Content-Disposition,attachment; fichero=\ + nombreBaseFichero + \;); response.setContentLength((int)gz.length()); ServletOutputStream sos; sos = response.getOutputStream(); FileInputStream stream = new FileInputStream(gz); BufferedInputStream bis = new BufferedInputStream(stream); InputStream is = new BufferedInputStream(bis); int count; byte buf[] = new byte[4096]; while ((count = is.read(buf)) -1) sos.write(buf, 0, count); is.close(); sos.close(); } - --- Dialog appears two times, and next any action i take, download's dialog appears. I read that action must return null but iit doesn't work. Can you help me, please??? Thanks in advance. - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]