Downloading multiple files in single response

skullface
skullface used Ask the Experts™
on
Hi,
I am building a web-applications using orion/ms-sql server.
I have a bunch of binary files.
I want the client to be able to download multiple files with a single click.
What i mean by a "single click" is that a request arrives to my servlet from the client. I process the request and want to send the client three to four files in a single response.
No this doesnot happen through a browser. There is a VB application on the client side which sends the request to my servlet and should recieve the files sent to it by the servlet.
An approx diag. is given below:

request files
| VB client | --------------> | my servlet | (this is trivial)


response
| VB client | <-------------- | my servlet |
               [file1][file2]
           (multiple files in a SINGLE response)

Is this possible at all? If not Why??
How do i accomplish it? Example pseudo-code will be a lot of help.
Will MultiPartResponse be able to handel it? I am using Orielly classes for multiple uploads in a single request.
How do i download multiple files in a single response?

I hope i have explained my problem. Please feel free to ask questions.

Thank you a lot in advance.
Skully.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
Commented:

Commented:
use mime multipart response format

Commented:
jspSmartUpload should be able to handle it... check out www.jspsmart.com
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Mick BarryJava Developer
Top Expert 2010
Commented:
MultipartResponse multi = new MultipartResponse(res);
 
 multi.startResponse("text/plain");
 out.println("Get set");
 multi.endResponse();
 
 try { Thread.sleep(1000); } catch (InterruptedException e) { }
 
 multi.startResponse("image/gif");
 ServletUtils.returnFile(req.getRealPath("/images/file1.gif"), out);
 multi.endResponse();

 try { Thread.sleep(1000); } catch (InterruptedException e) { }
 
 multi.startResponse("image/jpeg");
 ServletUtils.returnFile(req.getRealPath("/images/file2.jpg"), out);
 multi.endResponse();

 multi.finish();

Author

Commented:
i implemented the above solution..
but what happens here is that everything comes as a single "file". i mean single "save as" file.
i want multiple files coming as separate files to the application.

is that possible..
Mick BarryJava Developer
Top Expert 2010

Commented:
The client can either decode the response to extract the seperate file.
Or the servlet could send multiple response, each containing a single file.
Or the client could request the files one at a time.
Top Expert 2016

Commented:
Well, how did you alter the example code, reproduced by objects, to do what you want it to do? - i.e. post it please.
Mick BarryJava Developer
Top Expert 2010

Commented:
> reproduced by objects

not exactly, I modified it to show how to use MultiPartResponse to send multiple files. Which was what the question asked.

Top Expert 2016

Commented:
>>not exactly, I modified it ..

Yes, OK :-)
skullface:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.

Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Split points between CEHJ  and objects

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Venabili
EE Cleanup Volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial