Java Reference
In-Depth Information
public StudentList readStudentList(URLConnection connection)
StudentList list = null;
try {
// Create the ObjectInputStream passing it the
// InputStream object from the URLConnection
ObjectInputStream is = new ObjectInputStream(
System.err.println(“Waiting for response.”);
// Read the stored object and downcast it back to
// a StudentList
list = (StudentList)is.readObject();
catch (IOException e) {
catch (ClassNotFoundException ce) {
return list;
When you see how easy it is to serialize objects across an HTTP connection, or any other con-
nection, you really have to give credit to the people who wrote these classes. They have saved
all of us a lot of hassle. You will see again how easy it is in the next section, when you look at
the servlet side of an HTTP tunnel.
Creating an HTTP Tunneling Servlet
Now that you have seen the client side, let's take a look at the server side. The servlet example
will service requests from the StudentListTunnelApp . When it receives a request, it will read
the StudentList object from the InputStream and send it, unchanged, back to the client. The
source for the servlet is in Listing 6.4.
Search WWH ::

Custom Search