I am working on an application, which requires to transfer large files from server to client. I have a stand alone client which makes a request to a remote EJB. The EJB process the request and build an XML file of size about 50 MB and return it back to the client. What is the best way to do this? When I try to pass the file content as a String (inside a ValueObject), it throws out of memory exceptions frequently. What would be the optimal way of handling such a situation? please suggest
Thanx and Regards
The server-side stores the monster XML (I wonder what the hell that XML contains, by the way...) in a file or in a DB?
The EJB loads the hole file in memory and then returns it to the client?
Perhaps you should implement some kind of paging, so the client can query for chunks of the file and cache them on disk... I want to believe you don't handle the hole 50Mb in sserver side AND client side...
When you are dealing with large data you should implement your design by taking one of the transport protocol into consideration.
The transfer of data from one (server) to One (client) is nothing to do with any technology whether you using Java or Kava..
If you want a secured transfer, consider using SFTP or FTP/s. If you don't mind compromising security use FTP. Your client should have the required libraries packaged.
If you have restrictions in packaging additional libraries, you can go ahead with HTTP. JDK provides you HTTPURLConnection with no cost :)