Helping ordinary people create extraordinary websites!

Use Continuations to Develop Complex Web Applications

By Abhijit Belapurkar
2005-04-22

A Programming Paradigm to Simplify MVC for the Web
If you've ever developed a non-trivial Web application, you know that development complexity is increased by the fact that Web browsers allow users to follow arbitrary navigation paths through the application. No matter where the user navigates, the onus is on you, the developer, to keep track of the possible interactions and ensure that your application works correctly. While the traditional MVC approach does allow you to handle these cases, there are other options available to help resolve application complexity. Developer and frequent developerWorks contributor Abhijit Belapurkar walks you through a continuations-based alternative that could simplify your Web application development efforts.

Due to the inherent stateless nature of HTTP, Web technologies suffer from the problem of state information being forgotten between two successive user interactions. An interactive Web application consists of a collection of scripts wherein a single interaction comprises one script delivering a page to the browser (then ending), the user completing and submitting the form at some later point in time, and another (possibly different) script handling the submitted form. Thus, application logic is spread across a multitude of scripts.

Matters are further complicated by the fact that browsers allow users to backtrack in their interactions or clone an in-progress interaction and run both in parallel. Given this set of possibilities, a user can pursue multiple navigational paths within an application at any given time, and it's up to you to write code to ensure that each outcome is successful. Web development frameworks, such as Spring and Struts, allow you to handle multiple navigational paths, but they do so at the cost of increasing the complexity of an already overly complex code base.

In this article, I'll introduce a continuations-based alternative that can simplify the development of complex Web applications. I'll start with an introduction to continuations, including an argument for how the continuations-based approach can be a shot in the arm for the traditional MVC style of programming. Then I'll move on to a simple example: an enterprise application that demonstrates the advantages of using continuations in terms of ease of development and understanding of the application code. Because one of the chief disadvantages of using continuations is their lack of support on the Java platform, I'll use the Apache Cocoon framework to demonstrate a JavaScript implementation of the example program and a pure Java language one. I'll conclude with an overview of the pros and cons of using continuations.

Select the Codeicon at the top or bottom of this article to download the example application source code. See Resources to download the Apache Cocoon framework, which you will need to run the example.



Tutorial pages:

First published by IBM DeveloperWorks


 2 Votes

You might also want to check these out:


Leave a Comment on "Use Continuations to Develop Complex Web Applications"
You must be logged in to post a comment.

Link to This Tutorial Page!


GET OUR NEWSLETTERS