• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Downloading Multiple Files

 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 31
Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic