import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.IOException; import java.io.StreamCorruptedException; public class TestCGI { public static void main (String [] args) { Example5SerialObject so; try { ObjectInputStream ois = new ObjectInputStream(System.in); so = (Example5SerialObject)ois.readObject(); so.setTestInteger(so.getTestInteger() * so.getTestInteger()); String s = so.getTestString(); s = "From Applet: " + s + "\nFrom CGI: Got The CGI Script\n"; so.setTestString(s); ObjectOutputStream oos = new ObjectOutputStream(System.out); oos.writeObject(so); Example5SerialObject so2 = new Example5SerialObject(); so2.setTestInteger(5); so2.setTestString("2nd string"); oos.writeObject(so2); Example5SerialObject so3 = new Example5SerialObject(); so3.setTestInteger(10); so3.setTestString("A third string is written."); oos.writeObject(so3); } catch (StreamCorruptedException e) { System.err.println("Stream Was Corrupted!"); } catch (IOException e) { System.err.println("IOException Occurred!"); } catch (ClassNotFoundException e) { System.err.println("Class Not Found!"); } } }