Does anyone know if there is a way to access all the active session values at one. Is there anything built into the API that will allow me to check all the values that are part of every active session? For example, if I name and set a session attribute as "username", can I check all active sessions for the value of "username"? I think I could write a class that will keep track of the session id and then check the attribute values, but I was wondering if there was anything built in that will do this.
There are two ways to do this: 1. Write a session monitor class that implements HttpSessionBindingListener, and store an instance in each session that you create. There is a full example in chapter 7 of Instant Java Servlets - you can download the source code from http://www.philhanna.com - see Figures 7-14 through 7-19 in the xref. 2. Servlet API 2.3 (supported by Tomcat 4.0, among others) introduces event listeners for just this purpose. An HttpSessionListener is notified when sessions are created and destroyed, and an HttpSessionAttributesListener is notified when any session has attributes change. ------------------ Phil Hanna Sun Certified Programmer for the Java 2 Platform Author of : JSP: The Complete Reference Instant Java Servlets Website: http://www.philhanna.com
Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072127686/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072124253/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
Hi Phil Hanna! I need you answer to my question. I have bound a class to my session in a Servlet on iPlanet App server. I have to execute some code when the bound and unbound methods are called. I thought that the method unbound will be called when I remove the particular class from the session or when the session expires. I have verified the same with JWS. But in iPlanet the method valueUnbound() is called immediately after value bound is called. What will be the problem with it. Is there specail way to handle it in iPlanet App server? Bye! shyam