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