Define Listeners
The listener element of a web.xml file defines a listener instance. The listener element contains a listener-class element. Unlike filters or servlets, a listener does not have a name or a mapping. A listener element does not contain initialization parameters.
The listener-class element tells the servlet container how to load the listener. There are two components to this element: the base name of the shared library (.dll or .so) that contains the servlet, and the name of the function the container calls to construct the listener. The components of the element are separated by a single period.
The base name of a shared library is the name of the library file without the platform-specific prefix (if any), without the
12d or
15d suffix, and without the platform-specific extension. See
Appendix C for information on library name mappings for each platform that HydraExpress supports.
The function name in the
listener-class element must match the function name defined in the listener implementation. The
RWSF_DEFINE_LISTENER macro in the implementation source code defines the function name, as described in
“Defining Filters, Servlets, and Listeners” .
For example, the web.xml fragment below defines a listener in a shared library named listeners. The servlet container calls the function createTestListener to create the listener.
<listener>
<listener-class>listeners.createTestListener</listener-class>
</listener>
Since a listener cannot receive initialization parameters, should not allocate resources, and is not mapped to any specific URL, there is no need to create more than one instance of a listener class in the same context. For details on programming a listener, see
“Implementing a Listener” .