These days, Sun's bringing up the new specs for Servlets and JSP. Could you provide a couple of descriptive examples for the newly defined listeners (what events they are capable of handling and the objects generating these events).
Well, there are only two new Web application lifecycle event listeners in the new servlet 2.4 spec: ServletRequestListener and ServletRequestAttributeListener. These are slightly useful, perhaps, but hardly critical. So, if you are new to servlet and JSP programming, I definitely wouldn't start here. I wouldn't even start with listeners in general, even though the listeners that were introduced in the servlet 2.3 spec are a bit more generally useful (for details on their use, see Chapter 10 of
http://www.moreservlets.com/).
That being said, here is what they do:
ServletRequestListener: triggered when the the first servlet, JSP page, or filter in the chain starts processing the request. You might use this to introduce certain servlet request attributes for ALL requests (perhaps for testing and debugging how they handle certain situations) or for logging (eg to trace all requests that have a certain cookie). ServletRequestAttributeListener: triggered when someone adds, removes, or replaces attributes (not parameters!) in the ServletRequest. You usually use these attributes in the MVC architecture, so this listener might let you keep track of this, or automatically make side effects when certain attributes are added. Again, I do
not think that these two new listeners are very important, so don't focus on them if you are new to this technology.
Cheers-
- Marty