Use Continuations to Develop Complex Web Applications
By Abhijit Belapurkar2005-04-22
The Continuations Repository
It is important to maintain a continuations repository to manage the continuations for a Web application. One way is to have a global hash table with globally unique continuation ids maintained by the server providing the continuations infrastructure. This doesn't preclude one user copying and reusing the continuations id belonging to a different user from the browser. To prevent such occurrences, the tree of continuations can be maintained in a user's HTTP session, as well. In either situation, replicating the continuations repository will be necessary if running in a clustered environment. As mentioned, invalidating a continuation will cause the supporting framework to remove the entire object from the repository. Otherwise, such frameworks also provide for specifying a time to live for continuations such that expired continuations are automatically removed from the repository.
There are two options for sending the continuation id to the user's browser: It can be embedded as a hidden field in the form that is sent back, or it can be embedded in the URL to which the form will be posted. Needless to say, encapsulating continuation ids within cookies is a bad idea, because a specific cookie is common to all cloned instances of a browser window on a machine whereas a continuation is specific to a particular instance of the browser window only.
That's enough talk for now. The best way to make the case for continuations is to let you see them in action. In the following sections, I'll use an example application to demonstrate the simplicity of developing Web applications using continuations. To run the example application, you will need to download the Cocoon framework from Apache, because the Java platform by itself does not support continuations. See Resources to download Cocoon and learn about other Web development frameworks that support continuations.
Tutorial Pages:
» A Programming Paradigm to Simplify MVC for the Web
» What is a Continuation, Anyway?
» Problems in Conventional Web development
» The Case for Continuations
» User-Centered Navigation
» You Make the Rules!
» The Continuations Repository
» An Example Application
» Web Continuations in Apache Cocoon
» The Application Sitemap
» The Application Logic
» Understanding the Application Logic
» Resuming the Continuation
» JavaScript vs. the Java language
» Continuations in Java code
» Pros and Cons of Continuations
» Conclusion
» Resources
First published by IBM DeveloperWorks
