CHAPTER 8 PERSISTENT COMMUNICATIONS PATTERN 241 responseText, (Web hosting colocation)

CHAPTER 8 PERSISTENT COMMUNICATIONS PATTERN 241 responseText, responseXML) { if(status != 200) { throw new Error(”Post resulted in error (” + status + “) error text (” + statusText + “)”); } } client2Server.post(this.baseURL, mimetype, contentLength, content); } In the implementation of ClientCommunicator_send, the data is sent to the server and the response is forgotten. The response is not necessary because the writing stream does not process any received data, as that is the purpose of the reading stream. This enables the ClientCommunicator_send implementation to instantiate an instance of Asynchronous, assign the parameters, call post, and forget about the result that is generated. The property complete is still assigned to test whether the response code is actually HTTP 200. If the response code is not 200, something has occurred and the client needs to be informed. The best way to inform the client is to throw an exception with the details of the problem. Wrapping all of this together, the ClientCommunicatortype is a self-contained type that has separate writing and reading streams used to send and receive information updates. It must be stressed that the implementation of the ClientCommunicator does not discriminate or try to process the data that is sent and received. If the data sent from the server is a blob, the receiving client must process a blob. If the data is an incremental update, the client must process the incremental update. Implementing the ServerCommunicator For the scope of this section, the ServerCommunicator will be implemented by using a Java servlet. However, an ASP.NET handler that implements the IHttpHandler interface could have been used. What is important is the association of a resource and its children with a piece of functionality. So, for example, if the URL /resource is associated with a Java servlet, the URL /resource/sub/resource is also processed by the same Java servlet. The idea is that a single handler responds to processing a server-side resource. The following is an implementation of the Java servlet that processes the resource /ajax/ chap06/status, representing the base URL used by the client: import javax.servlet.http.*; import javax.servlet.*; import java.io.*; import java.util.*; import devspace.book.*; import devspace.book.definitions.*; public class GlobalStatus extends HttpServlet implements SingleThreadModel { static String _buffer; static long _callCount;
You want to have a cheap webhost for your apache application, then check apache web hosting services.

Leave a Reply