apache > cocoon

- Home

# Apache Cocoon - Control Flow

## Control Flow

Cocoon has advanced control flow, the ability to describe the order of Web pages that have to be sent to the client, at any given point in time in an application.

Traditional Web applications try to model the control flow of a Web application by modeling the application as a finite state machine (FSM). In this model, the Web application is composed of multiple states, but the application can be only in one state at a time. Any request received by the application transitions it into a different state. During such a transition, the application may perform various side-effects, such as updating objects either in memory or in a database. Another important side-effect of such a transition is that a Web page is sent back to the client browser.

For simple Web applications, this model works fine. However, as the application grows, the number of states and transitions between them grows as well, and it becomes hard to visualize what's happening in the application.

Moreover, the interactions in some applications are more complex than a simple finite state machine. In such cases it's much easier to think of and implement the application as a program, rather than a FSM.

By using a high level programming concept called continuations, Cocoon tries to solve this problem, and promises to allow the control flow in Web applications to be modeled as a normal program.

Errors and Improvements? If you see any errors or potential improvements in this document please help us: View, Edit or comment on the latest development version (registration required).