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]