This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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;
}
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!