Web hosting account - 280 CHAPTER 9 STATE NAVIGATION PATTERN The

280 CHAPTER 9 STATE NAVIGATION PATTERN The server will respond with an HTML page that contains no state information. If the loaded HTML page has implemented the State Navigation pattern, the implementation will start from the beginning. The state identifier loaded in the previous page (page1) is lost. The identifier is lost to the script, but in the history of the web browser the state identifier has been recorded. When the user clicks the Back button, the browser will make the request for the URL /ajax/chap07/page1, and the HTML page state with the identifier 11 will be loaded from the history. This again causes the State Navigation pattern to start from the beginning, except this time there is a state identifier requiring a state to be loaded. When the page from the resource has been loaded again, the onload function is called, causing the XMLHttpRequest object to search for the state with the identifier 11, and resulting in the following request: GET /ajax/chap07/page1/state HTTP/1.1 Accept: application/xml X-Page-Window-Name: window-2005-10-03-10-10-10-1245 X-Page-State: 11 Accept-Language: en-ca Accept-Encoding: gzip, deflate The server processes the request and generates the following response: HTTP/1.1 200 success X-Page-State: 12 Content-Type: application/xml;charset=ISO-8859-1 Content-Length: 364 Date: Sun, 18 Sep 2005 11:15:16 GMT Server: Apache-Coyote/1.1 In the response, the state identifier 12 is returned along with some data that the XMLHttpRequest object can process. Illustrating the State Navigation pattern visually and at the protocol level explains how this pattern functions. The remaining step is to explain how the client and server code make everything happen. Implementation For the State Navigation pattern to function properly, several other patterns need to be combined. Combining the patterns results in an overall architecture that is used to process requests. The question, though, is how to combine the various patterns. One solution would be to use the Decorator pattern. That would be a good solution, but is implemented by using the already-existing Decorator pattern facilities of the HTTP server. On the HTTP server side, the Decorator pattern is implemented using HTTP filters. An HTTP filter is used to modify or decorate the request and response, without actually changing the intention of the request. For example, to encrypt or decrypt the contents of the response or request, respectively, an HTTP filter would be used. On the client side, the Decorator pattern is not implemented as an HTTP filter, but as a series of encapsulations. Each encapsulation implements an added value functionality. Figure 9-12 is a graphical representation of the architecture in terms of layers.
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

Leave a Reply