Java Reference
In-Depth Information
Student 0 : Bob Robinson
Student 1 : Steve Bobinson
Student 2 : Rob Stevinson
Student 3 : Todd Thompson
Student 4 : Tom Toddson
Student 5 : Rob Bobinson
Press enter to quit.
Notice that the objects are exactly the same before and after being serialized.
Creating an HTTP Tunneling Client
Now that you understand Java serialization, let's put together an example using HTTP tunnel-
ing. The first part of this example is the client. This will be a simple application that opens an
HTTP connection to your servlet. It will then write the same StudentList object used in the
previous example to the open connection and wait for a response. The response will be the
original StudentList object echoed back to the client. The client can be found in Listing 6.3.
public class StudentListTunnelApp {
public StudentListTunnelApp() {
// Adds Student Names to List
public void buildStudentList(StudentList value) {
value.addStudent(“Bob Robinson”);
value.addStudent(“Steve Bobinson”);
value.addStudent(“Rob Stevinson”);
value.addStudent(“Todd Thompson”);
value.addStudent(“Tom Toddson”);
value.addStudent(“Rob Bobinson”);
// Write the StudentList to the Connection
public void writeStudentList(URLConnection connection,
StudentList value) {
Search WWH ::

Custom Search