Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
HydraExpress Servlet Development Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

2.5 Listeners and Events

Listener objects and event objects allow an application to respond directly to certain events. An event encapsulates information about a specific event in the HydraExpress servlet container, such as the container constructing a new session. A listener receives an event instance from the servlet container when an event occurs. Together, these two groups of classes provide a mechanism for reacting to events within a context independently of any particular request or any particular servlet. Further, some events occur outside of any servlet, and these events can only be handled by using a listener.

For example, a listener can assign a database connection to a new client when the client connects. When the client has been inactive for a certain period of time, the listener can close the connection. This approach is appealing for two reasons. First, the individual servlets in the context do not need to contain code for creating and closing connections. Second, a servlet is only active while processing a request and therefore cannot detect events, such as a timeout, that occur while no request is active.

HydraExpress provides base classes for creating listeners that respond to events that act upon sessions or contexts. For a discussion on programming listeners and handling events, see Section 6.6, "Implementing a Filter." Section 7.5, "Recovering Session State," describes the HydraExpress approach to associating objects, such as a database connection, with a specific client.



Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved. All Rights Reserved. Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. HydraExpress is a trademark of Rogue Wave Software, Inc. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.