274 CHAPTER 9 STATE NAVIGATION PATTERN Figure (Web design online)
274 CHAPTER 9 STATE NAVIGATION PATTERN Figure 9-9. An example of the state identifier being updated after the URL is copied to another web browser instance In the upper-left corner of Figure 9-9 is a web browser that has downloaded some content with the URL /resource#11. The loaded content is the resource /resource with the state identifier 11. Imagine the user opening a second browser and copying the link /resource#11. The State Navigation pattern will load the resource /resourceand the state associated with the identifier 11. In the second browser, the state identifier is updated to reference 12. If the second browser has the same state identifier as the first, that binds both browsers to the same state and creates concurrency problems. Imagine that the client modifies the state in the first browser; then the second browser would see the same state. This is not desirable, and therefore the state identifier 11is copied to a new state identifier 12. Then the first and second browser instances for the time being have the same state values, but different references. The solution in Figure 9-9 needs one additional twist to make it work properly. If the browser were to request the URLs /resource#11 and /resource#12, the resource /resource would be issued twice. This relates back to the purpose of the hash character, which is a reference to a link on an HTML page. This is a good thing, because the State Navigation pattern has separated the resource from the state of the resource. So when the resource /resource#11is called, the URLs /resource (for example, HTML page) and /resource/state (for example, HTML page state) are called. By using the XMLHttpRequest object, it is easy to separate the two URL requests, and there are multiple ways to implement the two URLs. But using two URLs is not enough. You also need to use HTTP headers to uniquely identify the request. Figure 9-10 illustrates how Figure 9-8 is fixed by using HTTP headers.
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.