Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Downloading Multiple Files

 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 728
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 728
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 728
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
cow clarke
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic