Listeners and Filters
This is a precis of topics covered in chapters 12 and 13 in
Fields, Kolb and Bayern.
Listeners
- Listeners execute methods when key events occur
- Examples of events include the following:
- Loading (i.e. initializing) a Web application
- Starting a user session
- Ending a user session
- Possible uses include the following:
- Starting and terminating a database connection for a user session
- Responding to user login and logout
Fields, Kolb and Bayern provide a database bean that uses a listener
to create and terminate a database connection. Note that the
valueBound and the valueUnbound methods are automatically called
when the session is respectively started and terminated.
Filters
- Filters modify or transform content originating from a servlet or JSP
- A filter operates as a separate module
- Possible uses include:
- Updating/modifying content without changing originating JSP
- Reformatting content to appear in specific browsers
- Transforming content into different formats (XML or WML)
- Restricting content to those who are logged in
Last modified: Wed Nov 05 12:44:02 Central Standard Time 2003