| <?xml version="1.0" encoding="UTF-8"?> |
| <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.0//EN" "../../dtd/document-v10.dtd"> |
| |
| <document> |
| <header> |
| <title>Advanced Control Flow</title> |
| <authors> |
| <person name="Ovidiu Predescu" email="ovidiu@apache.org"/> |
| </authors> |
| </header> |
| |
| <body> |
| <s1 title="Cocoon and continuations"> |
| <p>With continuations in the language, you can essentially |
| store the continuation of <code>sendPageAndWait()</code> (think of all |
| the stack trace, and the program counter), put it in a global |
| hash table associated with an id. The id is then encoded in |
| the <code>response.xml</code> page as an URL. When the user |
| clicks on that URL, on the server side the associated |
| continuation is resumed. Resuming the processing happens as if |
| nothing was stopped, you get all the stack trace back, and all |
| the local variables.</p> |
| |
| <p>So instead of using beans to store things in session, you |
| use normal variables in a program. Since each user has its own |
| version of the program, all the local variables in the program |
| are separate between users.</p> |
| |
| <p>With this approach clicking the <em>Back</em> button in the |
| browser is no longer a hassle to deal with for you as a |
| server-side programmer. They will simply refer to past |
| continuations objects, which have their own state of the local |
| variables.</p> |
| |
| <p>Since continuations are objects, you can also store them in |
| a database, for really long-lived session, just like you do |
| with session beans.</p> |
| </s1> |
| |
| </body> |
| </document> |