Giriş
Şu satırı dahil ederiz
import javax.servlet.http.HttpSessionAttributeListener;
Açıklaması şöyle
The HttpSessionAttributeListener interface is for receiving notification events about session attribute changes. The order in which its implementations are invoked is unspecified.Örnek
Şöyle yaparız
import javax.servlet.http.HttpSessionBindingEvent;import javax.servlet.http.HttpSessionAttributeListener;import javax.servlet.annotation.WebListener;@WebListenerpublic class MyHttpSessionAttributeListener implements HttpSessionAttributeListener {@Overridepublic void attributeAdded(HttpSessionBindingEvent event) {System.out.println("session attr " + event.getName() + " added with value " +
event.getValue());}@Overridepublic void attributeRemoved(HttpSessionBindingEvent event) {System.out.println("session attr " + event.getName() + " removed with value " +
event.getValue());}@Overridepublic void attributeReplaced(HttpSessionBindingEvent event) {System.out.println("session attr " + event.getName() + " replaced with value " +
event.getValue());}}
Hiç yorum yok:
Yorum Gönder