Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Multiple file download

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Im facing a dilemma at the moment. Can anyone figure out how to download multiple files? My initial solution was to use: "window.open()" in javascript and then call the page that downloads by looping. Unfortunately, the window that is opened does not close even after the download ends. My client does not want this to happen. Even if I invoke the window.close(), the window still does not close.
Here is a code snippet:
***************************************************************************
for (i=0; i<iNoOfElements; i++) {
fileName = "fileID" + i;
fileID = document.getElementById(fileName).value;
window.open("Download.jsp?filename=" + fileID, "down", "width=1, height=1");
***************************************************************************
Now, can anyone suggest a new method? Another way would be to zip the files but my client does not want it either.
Any help is very much appreciated. You can reach me through j_maratas@yahoo.com.
Thank you and best regards.

Jen
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like you are out of luck!

I would say zipping the files saves bandwidth which means saves them money.

Only thing I would say to try is this:

and see if it does not mess with the download.

Eric
 
Jeramie Maratas
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help..
But i used a different approach and it worked. What i did was i created several iframes depending on how many files to download. Then, when the client clicks the download button, i have a javascript that iterates and sets the source ("src") of those iframes into another JSP that handles the download.
Here is a sample code:
for (i=0; i<iNoOfElements; i++) {
if (document.getElementById && document.getElementById(getIDOf) != null) {document.getElementById(getIDOf).src = "Download.jsp?filename=" + fileID;
}
else if (document.layers && document.layers[getIDOf] != null) {
document.layers[getIDOf].src = "Download.jsp?filename=" + fileID;
}
else if (document.all) {
document.all[getIDOf].src = "Download.jsp?filename=" + fileID;
}
}
 
catch it before it slithers away! Oh wait, it's a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic