Maintaining state on the server

Using a stateless component

The Web DataWindow can run in a fully stateless server environment. Variables in the Web page keep information about the rows being viewed and any changes the user makes; this information is communicated to the server component as needed so that the component can restore its state each time it is called. Restoring its state includes retrieving data from the database each time the page is reloaded, including each time the user navigates to another page.

Operating in a stateless mode minimizes use of server resources but can decrease performance. The client maintains the state of the server component in string form and the information is sent back and forth with every request. Also, when state is not maintained on the server, the component must connect to the database and retrieve data each time it is called. If the component server does not do connection caching, response time for the client could be very slow.

Using a stateful component

You can increase performance by maintaining state on the server. To maintain state, the page server’s session object keeps a reference to the server component. If the server component is running in EAServer, you must mark the component as a stateful object and set a timeout value for the component. Failing to set a timeout value if you are using the component as a stateful object will result in orphaned instances of the component on the server.

Maintaining state on the server provides faster response time if the same component is accessed again. However, it also increases the server resources used for each client connection.

To minimize impact on server resources, a short timeout on a session lets the server get rid of a component that might not be requested again. If the component is called again, its state can be restored from the client state information. When the number of hits on a page is expected to be large, setting a shorter timeout reduces the number of instances that need to be maintained simultaneously.

Marking the object as stateful

To mark the component as a stateful object, set the component’s com.sybase.datawindow.serverSideState property in EAServer Manager or call the SetServerSideState method in a server-side script:

dwGen.SetServerSideState( true );

You should not set the com.sybase.jaguar.component.stateless property for the HTMLGenerator125 component in EAServer Manager.

Setting timeout values

To set the timeout value for the HTMLGenerator125 component, open its Component Properties dialog box in EAServer Manager and set the com.sybase.jaguar.component.timeout property. Timeout values are specified in seconds; a value of 0 means the component never times out.