aspose file tools*
The moose likes JSP and the fly likes Multiple file download Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Multiple file download" Watch "Multiple file download" New topic
Author

Multiple file download

joan wo
Greenhorn

Joined: Mar 12, 2007
Posts: 9
Hi,

There is any way for multiple file download?
I have a jsp with differents checkbox, the user can check different checkbox's and then submit the action. I want to know how donload all the files linked to the checkbox's.

I've tried to call an action from a javascript file for every checkbox but appear a "Connection reset by peer" on the second file (for only one file runs ok).

Thank's in advance
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

One approach is to bundle all of the files into one zip file.
See: http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/package-frame.html


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
joan wo
Greenhorn

Joined: Mar 12, 2007
Posts: 9
Hi,

But in my case the users have to download the files separetelly. I've tried to open a new window from javascript and call an action and run ok, but:
- If use a "atachment" option in the Header show an empty window
- If use a "inline" option in the header show the pdf file into the new screen but the document has lost it's name (when choose save option of the file), and for the user is very important the name of the file. I use this:

response.setHeader("inline; filename=\"" + fileName + ".pdf\"", "content-disposition");



Thank's for the reply.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by joan wo:

response.setHeader("inline; filename=\"" + fileName + ".pdf\"", "content-disposition");


This is backwards.
The first argument should be the header name.
To see an example of a properly formed Content-Disposition tag go to:
http://faq.javaranch.com/java/JspAndExcel
[ March 18, 2008: Message edited by: Ben Souther ]
joan wo
Greenhorn

Joined: Mar 12, 2007
Posts: 9
Hi,

I call the action from a javascript function:

window.open("printPDF.do"+"?sPrint="+list[i].value,"_blank",);

In the java action I make:

ouputStream = response.getOutputStream();
response.setContentType ("application/pdf");
response.setHeader("Content-Disposition", "inline; filename=\""+nameFile+"\"");
ouputStream.write(docPDF, 0, docPDF.length);ouputStream.flush();
ouputStream.close();

I think this code is correct, and in fact, I can see the pdf file correctly, but if I try to save the file in my computer (using the "Save as...") the name of the file is not nameFile, the name is "printPDF.pdf". I don't know why.

Thank's a lot
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple file download