• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple file download

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
joan wo
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic