Maintain connections and application state across pages

The scope of a JavaScript variable is limited to one web page. Most web applications require multiple pages, and so a mechanism is needed for making some objects persistent across the pages of an application.

UltraLite for M-Business Anywhere provides persistence for the ULTable, ResultSet, and PreparedStatement objects. To make one of these objects persist across pages, supply a persistent name as a parameter when creating the object. You can use the persistent name on subsequent pages.

To carry a connection object from page to page, you reopen the connection on each page. One way to do this is to use the reOpen method. Another is to supply an open method on each page, perhaps by including a JavaScript file on each web page to initialize the settings. For examples of how to do this, see the sample files C:\Documents and Settings\All Users\Documents\SQL Anywhere 12\Samples\UltraLiteForMBusinessAnywhere\CustDB\main.htm and C:\Documents and Settings\All Users\Documents\SQL Anywhere 12\Samples\UltraLiteForMBusinessAnywhere\Simple\main_page.htm.

The requirement to reopen connections across pages provides a security feature for UltraLite applications. You can use it to require that the user confirm some information, perhaps the password, on moving from page to page.

If an UltraLite object is not needed in another web page, the application should issue a close method on the object to save memory.

 See also