How to send multiple files from server to client

Here i am trying to send multiple files in single request.

For this i used ObjectOutputStream. i created FileData object. FileData Object data contains file information in bytes.after that i am sending this data object to client using ObjectOutputStream. But here i am getting one problem. If the FileData size is more than 50 MB i am unable to send this. I am getting out of memory Exception. How can i resolve this problem

[437 byte] By [venkatakotiy@gmail.coma] at [2007-11-27 7:58:05]
# 1

Don't do it this way. Read from a FileInputStream and write to a SocketOutputStream on the client, and on the server read from a SocketInputStream and write to a FileOutputStream. Simply have them negotiate beforehand how large the file is so the server knows when to stop writing to the file, or use "Starting" and "ending" tags to denote the name, start, and end of the file being transferred. There is absolutely no reason, whatsoever, to attempt to pass an entire file as an Object.

masijade.a at 2007-7-12 19:39:58 > top of Java-index,Java Essentials,Java Programming...
# 2
Don't do that. Don't ever write code that reads an entire file into memory. Just send the bytes of the file, a chunk at a time, using the write methods of OutputStream.
ejpa at 2007-7-12 19:39:58 > top of Java-index,Java Essentials,Java Programming...
# 3
Hi,thanks, for u r response. Here the communication is going on Applet to Servlet. Is there any possible way to transfer multiple files at a time
venkatakotiy@gmail.coma at 2007-7-12 19:39:58 > top of Java-index,Java Essentials,Java Programming...
# 4

Have the Applet perform a File Upload to the server for each file one at a time, after getting an entire list of files from the user.

The Applet will not be able to transfer files to a Servlet in any other manner, unless the servlet is doing things it should not be (i.e. opening its own socket, etc), since a Servlet (assuming a normal web application here) is designed to respond to HTTP requests.

At least (AFAIK) it cannot (or at least should not) be done in any other way.

Edit: You could perform each File Upload in its own thread, thereby parallelising them, but I shouldn't think it necessary to perform them simultaneously, serially should be good enough.

masijade.a at 2007-7-12 19:39:58 > top of Java-index,Java Essentials,Java Programming...