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

Downloading Multiple Files

Saathvik Reddy
Ranch Hand

Joined: Jun 03, 2005
Posts: 228
Hi,

I want to download multiple files on a http request. I am aware that i can zip all the files and then download the zip as a single file.

Are there any other options (like AJAX or applets) that could achieve this?

How does sun download manager download files?

Thanks,
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Srikanth,
By definition, you can download one thing at a time. The choices are zipping it up (which you've considered) or downloading them one at a time. AJAX or Applets could provide different graphical options for downloading one at a time, but does not change the underlying architecture.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Saathvik Reddy
Ranch Hand

Joined: Jun 03, 2005
Posts: 228
Jeanne,

My requirement says: I have to download 10 files in response to an HTTP Request.
For each file the browser has to display save dialog box(10 times). This all should happen in a single HTTP Request. My requirements doesn't want to zip the files. Is there any way to achieve this?

Can i say this requirement is not feasible to my Business Analysts.


Thanks in Advance,
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 686
Has your BA seen this done?
If the response can contain multi-part data, then you could put content-type, content-length and content-disposition response fields along with the data in the response. My HTML text discusses it under "Server-Push"
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Srikanth Reddy:
Is there any way to achieve this?

No
Can i say this requirement is not feasible to my Business Analysts.[?][/QB]

The analyst should have had a technical consultant in the room before he decided this.

That being said, you might be able to make it appear that you have achieved this with Javascript and iframes.
Would you like me to move this to our HTML/Javascript forum?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Saathvik Reddy
Ranch Hand

Joined: Jun 03, 2005
Posts: 228
Originally posted by Norm Radder:
Has your BA seen this done?
If the response can contain multi-part data, then you could put content-type, content-length and content-disposition response fields along with the data in the response. My HTML text discusses it under "Server-Push"


Could you please point me to some sample code.
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 686
Sorry, I only have printed text (HTML4.0 Sourcebook by Ian Graham) and no code examples. The text implies that a server can send multiple files to a browser that will cause the browser to prompt the user to save each file.
Try Searching for multipart and Server-push
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 686
Just to verify the above is possible I wrote a Q&D servlet for "my HTTP server" to demo multiple file down loads. I was able to get the browser to prompt for and save two files with a single HTTP GET with the following code:

[ July 03, 2008: Message edited by: Norm Radder ]
ghetolay priver
Greenhorn

Joined: Nov 14, 2009
Posts: 1
line 52 :

byte[] endBndry = (boundaryTxt + "--").getBytes();

instead of

byte[] endBndry = (boundary + "--").getBytes();



It's work better, because you were confounding byte and string.

Good Work really nice piece of code
Oscar Costa
Ranch Hand

Joined: Feb 05, 2009
Posts: 31

The problem is that IE don't implements "multipart/x-mixed-replace"...

What's it can be a solution to IE? Create a Zip file?


"Do or do not... there is no try!" - Jedi Master Yoda
> SCJP 5 : SCWCD 5 : SCBCD 5 <
cow clarke
Greenhorn

Joined: Nov 12, 2009
Posts: 15
I don't think it is a problem.

First you shoul have the zip process ablility in the server size, then zip the files you want to send to the client, then open a binary output stream to transfer it.

That is all. what more J2SE include the ability to zip files.
Oscar Costa
Ranch Hand

Joined: Feb 05, 2009
Posts: 31

Yes, I have done it...

The files are generated by the JasperReports, then I just got the OutputStream of each one and wrote it in the ZipOutputStream... Very simple.

Thanks...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Downloading Multiple Files