Example of Object Serialization With JavaCGIBridge

Demonstration

This example demonstrates using Object Serialization with the JavaCGIBridgeExtension class. JavaCGIBridgeExtension contains extra methods for sending and receiving serialized objects via the Applet to and from a CGI application written in Java.

The first thing that occurs is that a sample string appears in the TextArea. By default, this string is "Test String From Applet!". You may keep this or replace it with the text you want.

Then, when the "Call CGI Script" button is pressed, this string as well as some integer information is written to an object called Example5SerialObject.class. This object is serialized and sent as pure raw data to the CGI script which calls a Java program to decode the serialized data and replace it with its own. In addition, the Java CGI app also sends several other instances of the object back just to show that a stream of objects can be sent back.

Finally, the string contents of the objects are displayed in the text area. This includes the original string you had typed in since the Java CGI app took that string and made it part of a large string just to show that the information was indeed being sent over properly.

Serialization Notes: This will only work in JDK 1.1 browsers. In addition, you need to be careful about the version of the classes in your browser versus the version on the CGI side. If the version of the classes is wrong, then the serialization may not work.

Unlike the previous examples, there is no plain CGI script to demonstrate since it expects to receive serialized data.

Example Object Serialization Applet

View The Source To Example5Applet.java

View The Source To Example5SerialObject.java

View The Source To JavaCGI Bridge.java

View The JavaCGIBridge JavaDoc File

View The Source To JavaCGIBridgeExtension.java

View The JavaCGIBridgeExtension JavaDoc File

View The Source To JavaCGIBridgeTimeOutException.java

View The JavaCGIBridgeTimeOutException JavaDoc File

View The Source To test_serial.cgi

View The Source To TestCGI.java

Gunther Birznieks <gunther@clark.net>