Java Reference
In-Depth Information
L ISTING 6.3
Continued
System.err.println(“Waiting for response.”);
// Read the stored object and downcast it back to
// a StudentList
list = (StudentList)is.readObject();
is.close();
}
catch (IOException e) {
System.err.println(e.getMessage());
}
catch (ClassNotFoundException ce) {
System.err.println(ce.getMessage());
}
return list;
}
public void invoke() {
try {
StudentList list = new StudentList();
buildStudentList(list);
// create our URL
URL url = new URL(“http://localhost/djs” +
“/servlet/StudentListTunnelServlet”);
// Open our URLConnection
System.err.println(“Opening Connection.”);
URLConnection con = url.openConnection();
// Write the StudentList
writeStudentList(con, list);
// Get the StudentList from the response
// and print it out.
StudentList inList = readStudentList(con);
if ( inList != null ) {
System.out.println(“After being read back in.”);
inList.listStudents();
Search WWH ::




Custom Search