ProcessRequestStats
ProcessRequestStats
/processStats
Chapter 6 ?– The Application Events Framework 322
6.13 Watching Servlet Request for
Attribute Changes
The ServletContextAttributeListener monitors the life cycle of application
scope attributes and the HttpSessionAttributeListener monitors the life
cycle of session scope attributes. Likewise, version 2.4 of the servlet specification
introduced a listener that monitors the request scope attributes: Servlet-
RequestAttributeListener. The container notifies this listener when an object
is placed into the request scope for the first time, replaced by another object, or
removed from the request scope altogether. The use of the ServletRequest-
AttributeListener interface is almost identical to the use of its ???sister??? listener
interfaces: ServletContextAttributeListener and HttpSession-
AttributeListener. Details follow.
1. Implement the ServletRequestAttributeListener interface.
This interface is in the javax.servlet package.
2. Implement attributeAdded, attributeReplaced, and
attributeRemoved. The attributeAdded method is triggered
when a new attribute is added to a request. When a new value is
assigned to an existing request attribute, attributeAdded is triggered
with the new value and attributeReplaced is triggered with
the old value (i.
Pages:
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375