We help IT Professionals succeed at work.

Web app continuations in layman terms

Johny_Brav0 asked
I just cannot get my head around the concept of continuations. Please someone put it in an easy way or point me to somewhere this is done.

What I understand:
Its a programming style to help with situations such as checkouts in web apps i.e. long series of steps including address entry, payment details etc. ending in conformation.
When not using continuations, using the back button can disrupt the flow cause "crash" - its hard to maintain state in such a situation (HTTP is stateless).
So continuation makes more statefull, maybe stores previous, current and future actions so that undo is easier? Like making another copy of a string when a change is made to it, so you can undo to the previous stored string?

Thanks anyone
Watch Question

Dave BaldwinFixer of Problems
Most Valuable Expert 2014

A Google search for 'continuations' bring up a wide variety of definitions.  I think what you're looking for is two particular things.  Number one, information submitted by the user is stored in a database so it can be retrieved when needed during the process.  Number two, 'redirects' are used so that pages that add data to the database can't be reloaded with the 'back' button.  The Form page posts to a server page that adds data to the database.  But the user never sees that server page because it redirects to another page that loads whatever data is needed for the next display page.  Since the page that the user's browser sees Only loads data, 'back' will only load data without corrupting the database.


I understand most of what you said but need clarity on following:

"The Form page posts to a server page that adds data to the database."
Is this like MVC i.e. form page being view and server page being model allowing separation of concerns benefits like allowing designers to work on view without worrying about code of model?

Fixer of Problems
Most Valuable Expert 2014
No, it's not like that.   Pages that run on the server without sending anything to the browser are really 'programs' that do things for you like adding data to the database.  Since the browser never sees any output from them and doesn't see their address in the address bar, you can't use the 'back' button or 'refresh' to get to them.  

So the process is Form page (in the browser) -> database page (on the server) -> results page (in the browser).  When you get to the results page, clicking on 'back' will take you to the Form page because that was the previous page in the browser.  Since you can't go 'back' to the database page where the data is added to the database, you can't accidentally send the data to the database page a second time.