Communication between servlet & rich client - ObjectStream or OutputStream?
Hi,
I need to send a text file from a servlet to a rich client. Is it better to send it over OutpputStream or wrap it up as an Object(eg: StringBuffer) and send it over OutputStream?
Will the performance be significantly be affected if I try to wrap the file into an object at the Servlet's end and send it over ObjectStream? We are planning to wrap all responses from the servlet into a generic response object (containing data, exceptions and error codes if any) and send it to the client
Please advice. Thanks in advance!
[550 byte] By [
sreegaua] at [2007-10-3 2:26:12]

Using object streams will create some protocole overhead. But you can minimize the effect by using compression.
Ex:- java.util.zip.GZIPOutputStream & GZIPInputStream
If you have already decided to use a genaric responce object then it will be good to have a generic request object too that will make your communication more flexible.
But remember when you are doing serialization you might get problems when having different java versions in different ends if your object structures use data structures provided by java API (Ex:- Collections). You can work arround this problem (In most cases) by implementing custom serialization using writeReplace and readResolve methods.
LRMKa at 2007-7-14 19:25:16 >
