Adding channel sessions for HTTP devices

You can also manage channel sessions specifically for devices that use the HTTP communication protocol. An implementation using the toolkit and the HTTP protocol requires that cookies be enabled on the client and server to manage the channel session.
To manage channel sessions for an HTTP device, complete the following steps:
  1. Create an HTTP-specific ChannelSessionHandler.
  2. Configure the servlet engine for inactivity timeouts.
  3. Create an event class that will be used to notify registered listeners that the session has expired.
  4. Implement the event listener for the event class created in the previous step.

Creating an HTTP-specific ChannelSessionHandler

Create an instance of the HttpChannelSessionHandler. The HttpChannelSessionHandler is a specialized ChannelSessionHandler that implements the HttpSessionBindingListener interface. The handler receives notification of the HttpSessionBindingEvent when the session is added to or removed from the servlet engine session manager (that is, WebSphere®). When the instance is created, the CSServer is added as a registered listener for the ChannelSessionStateChangedEvent.

The application must register to CSServer as a listener of the event. When an event is fired, the application may use the protocol available in the Context class to eventually remove session information from the application session table if the session has expired due to a timeout.

Configuring the servlet engine for inactivity timeouts

Configure the servlet engine implementation to enable sessions and set the invalidation time.

Creating an event class

Create an instance of the ChannelSessionStateChangedEvent, which uses the session ID obtained from the HttpSessionBindingEvent object. This object contains a reference to the HttpSession object that has expired. When the session expires, the ChannelSessionStateChangedEvent is fired to all registered listeners.

Implementing an event listener for the event class

Implement the ChannelSessionStateChangedEventListener. The CSServer implements this interface and is notified when the session is removed by the channel session manager. The CSServer is responsible for firing the CSInactivityClientEvent. The application must be a registered listener so that it can remove the session from the application session table and perform any other cleanup.