Java Reference
In-Depth Information
L ISTING 6.4
Continued
6
System.err.println(cnfe.getMessage());
}
}
//Get Servlet information
public String getServletInfo() {
return “StudentListTunnelServlet Information”;
}
}
As you can see, this is a very simple servlet. The service() method is where all the function-
ality is located. The StudentList objects are written and read just as they were on the client
side. The same three-step process is used on both sides.
A Practical HTTP Tunneling Example
You will now put HTTP tunneling to work in a practical example. Your example will be a real-
time order status tool. You will use an applet as your client side, which will be called
OrderStatusApplet . It will send a serializable order object to the OrderStatusServlet . This
servlet will then read the object off the wire, update the status attribute, and send the object
back to the applet. Listing 6.5 contains the source code for the Order object.
L ISTING 6.5
Order.java
import java.io.*;
// Notice this object implements the Serializable interface
public class Order implements Serializable {
// This attribute holds the Order#
private String order = new String(“”);
// This attribute holds the Status of the Order
private String status = new String(“”);
// Default Constructor
public Order() {
}
// Accessor used to set the Order #
 
Search WWH ::




Custom Search