aspose file tools*
The moose likes Servlets and the fly likes Multiple file download Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Multiple file download" Watch "Multiple file download" New topic
Author

Multiple file download

lakshmi ananthamurthy
Greenhorn

Joined: Apr 26, 2001
Posts: 5
I need to know if there is any way that we can do a multiple file download using servlets, NOT using Client pull (cause we cannot use Javascript), and save the files as separate files and not as a single file, and all this in one single connection..
the user should not have to keep chosing the file which he wishes to download.
I tried setting the mime type and working that out, but it seems to be giving problems.
manav kher
Ranch Hand

Joined: Nov 21, 2000
Posts: 98
let me know if u figure that out..we have a similar situation and as faras i know that would pop up the file-save/open input box multiple times
-manav
Phil Hanna
Ranch Hand

Joined: Apr 05, 2001
Posts: 118
How do you expect to do this without user intervention? There is always a prompt in the browser for where to save the file, because the user complete control over this. You can't dictate where they place files on their machine.
Have you thought of sending a .zip file? That way it could have a collection of files.
------------------
Phil Hanna
Sun Certified Programmer for the Java 2 Platform
Author of :
JSP: The Complete Reference
Instant Java Servlets
Website: http://www.philhanna.com


Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072127686/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072124253/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
lakshmi ananthamurthy
Greenhorn

Joined: Apr 26, 2001
Posts: 5
The requirement of the client is that he does not mind if the pop ups keep coming whether or not you wish to save the file or open it, but the user should not have to keep browsing and chosing the file to download.
arul narayan
Greenhorn

Joined: Sep 26, 2000
Posts: 17
Hi,
I also have a similar requirement. Can someone suggest ways to do this.
I also do not mind using javascript to do this. Using javascript, I am able to download only one file at a time, but I need to download multiple files selected by the user by checking check boxes and clicking a button.
Please suggest ways to download multiple files.
Thanks.


arul.
Vlad Patryshev
Ranch Hand

Joined: Jun 30, 2001
Posts: 61
Guys, if I understand the problem correctly, javascript cannot help. It is downloading files to the client machine without the user's initiative. It is kind of against security. You can do it in applets, though, but there ought to be some security settings permitting a specific applet to do so. Javascript will not download files.


Thanks,<br />Vlad
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

After having a think about it, it should be possible, but if you try this on me I'll come after you... I'd only try this if the client is EXPECTING multiple files.
In the HTML returned to the client, have javascript that opens multiple new windows and have the target for each of these windows as the file you want the client to download.
eg (pseudocode)
<javascript>
window.open("http://location/file1.doc");
window.open("http://location/file2.mp3");
window.open("http://location/file3.xls");
//etc etc
</javascript>
Dave.
Cameron Park
Ranch Hand

Joined: Apr 06, 2001
Posts: 371
Can you open a URLConnection and create files in the client drive?
arul narayan
Greenhorn

Joined: Sep 26, 2000
Posts: 17
Thanks a lot David,
I followed your suggestion and it worked fine exactly the way I wanted. The windows get closed as soon as the download is complete which is fine. Ideally though, it would have been better if there is only one pop up box to download all the files.
The alternate working solution that I had was using a signed applet to do the downloads sequentially once the user selected the files and hit the download button. This had only one applet window open to do all the downloads. But the client did not want to do anything with applets and certificates.
Hence the javascript route is fine.
Thanks again for all the responses.
Susan Atmaja
Greenhorn

Joined: Feb 02, 2004
Posts: 2
Is there a way to accomplish this without using javascript?
i.e. Just using simple html code. I believe it would involve setting of the http header. Please advise. Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple file download