Hi, Thanks for the response for the first post! To expand on the previous question: essentially what I want to do is stream a large amount of data from the servlet to the applet. What I need to do is send this data in blocks. For example, I have an array of 1000 objects (all serializable) and I want to send them to the applet in blocks of 100....all within the same request. What are the issues here? Can I send more than one block (array of objects) via the ObjectOutputStream.writeObject() method without closing the output stream? (Or...what is the best way to do this?) How should the client handle this? I also noted that the code you pointed me to (in the com.javaranch.common package) is using GZIPInputStream. What are the advantages and disadvantages of this? Thanks again. -Jeff
Jeff Wisard<br />Sun Certified Java Programmer (Java 2)<br />Sun Certified Web Component Developer
Sending multiple objects is as simple as putting them all in a Vector! Although you can also serialize multiple objects by writing explicit code to write them one at a time, it is just simpler to send a Vector. The GZIP stream can make the transimission more compact and also make it harder to snoop, but at the expense of CPU time.
Thanks for the response. Apparently, I did not make myself clear. I have a LARGE amount of data to pass back to the applet. Without getting too detailed, this data is returned from a CORBA object to the servlet as an array of structures where each element represents a row in a database table. So each row, in itself, is actually several objects. I want to display this data as a stream to the user of the applet as it is coming in. Thus, I need to send the data to the applet in blocks. Yes, I can package each block of data into a Vector or a serialized ArrayList. But the issue still remains: How do I send multiple blocks of data? How would I handle sending, as you state, more than one vector back to the applet? (And don't say 'send it as a Vector of Vectors'. That still defeats the purpose. ) Thanks, again. -Jeff Wisard
Author and all-around good cowpoke
Joined: Mar 22, 2000
In that case, object serialization is probably not what you need. It gets slower and less efficient as the bulk grows. Furthermore, it can consume a lot of memory in the course of reconstructing the data. Instead, I think you will have to create some compact representation based on your knowledge of the data. Essentially writing your own serializer but not using the object stream methods.
If this was my problem I would create some sample data files and try reading and decoding them in the applet environment. You will obviously need a separate Thread on the Applet side that will grab data rows as they are transmitted and make them available to the display Thread. Only after getting the reading working would I try to put the whole thing together. Bill