Servlet Development Guide : PART III Programming : Chapter 6 The Servlet API : Defining Filters, Servlets, and Listeners
Defining Filters, Servlets, and Listeners
Each filter, servlet, or listener implementation must contain a macro that expands to a create function. The Agent uses this function to load an instance of the class.
The name of each macro starts with RWSF_DEFINE. HydraExpress includes two macros for each type of object, as shown in Table 2 :
Table 2 – Macros for defining filters, servlets, and listeners 
Macro
Expands to Function Name
RWSF_DEFINE_SERVLET(ServletClass)
createServletClass
RWSF_DEFINE_SERVLET_NAME(ServletClass, functionName)
functionName
RWSF_DEFINE_LISTENER(ListenerClass)
createListenerClass
RWSF_DEFINE_LISTENER_NAME(ListenerClass, functionName)
functionName
RWSF_DEFINE_FILTER(FilterClass)
createFilterClass
RWSF_DEFINE_FILTER_NAME(FilterClass, functionName)
functionName
Of the two versions of each servlet, listener, and filter macro in Table 2 , the first listed uses the default function name “create<typeofClass>. For example, the macro RWSF_DEFINE_SERVLET(MyServlet) expands to the function createMyServlet in the class, MyServlet. The Agent uses the function to construct an instance of the servlet.
 
RWSF_DEFINE_SERVLET(MyServlet)
This is referenced in the servlet configuration file web.xml:
 
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>MyServlet_library.createMyServlet</servlet-class>
</servlet>
The second macro, RWSF_DEFINE_SERVLET_NAME(ServletClass, functionName) allows you to create a custom function name that is more relevant to your own applications, such as:
 
RWSF_DEFINE_SERVLET_NAME(MyServletClass, generateServlet)
In this example, the function name will be generateServlet instead of createServletClass, and web.xml will define the servlet like this:
 
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>MyServlet_library.generateServlet</servlet-class>
</servlet>
Note the servlet configuration above indicates that class MyServlet has been built into the shared library, MyServlet_library.
See Chapter 4 for information on adding filters, listeners, and servlets to the servlet container.