aspose file tools*
The moose likes Servlets and the fly likes Passing more than one object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Passing more than one object" Watch "Passing more than one object" New topic
Author

Passing more than one object

Jeff Wisard
Ranch Hand

Joined: Jan 07, 2002
Posts: 89
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
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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.
Jeff Wisard
Ranch Hand

Joined: Jan 07, 2002
Posts: 89
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
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing more than one object