16 Aralık 2021 Perşembe

Servlet HttpSessionAttributeListener Arayüzü

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;

@WebListener
public class MyHttpSessionAttributeListener implements HttpSessionAttributeListener {

  @Override
  public void attributeAdded(HttpSessionBindingEvent event) {
    System.out.println("session attr " + event.getName() + " added with value " +
event.getValue());
  }

  @Override
  public void attributeRemoved(HttpSessionBindingEvent event) {
    System.out.println("session attr " + event.getName() + " removed with value " +
event.getValue());
  }

  @Override
  public void attributeReplaced(HttpSessionBindingEvent event) {
    System.out.println("session attr " + event.getName() + " replaced with value " +
event.getValue());
  }
}

Hiç yorum yok:

Yorum Gönder

Bean Validation @GroupSequence Anotasyonu

Örnek Elimizde şöyle bir kod olsun public class SampleRequest {   @NotNull   LocalDate startDate;   @NotNull   LocalDate endDate;   @AssertT...