16 Aralık 2021 Perşembe

Servlet HttpSessionListener Arayüzü

Giriş
Şu satırı dahil ederiz
import javax.servlet.http.HttpSessionListener;
Açıklaması şöyle
The HttpSessionListener interface is for receiving notification events about session lifecycle changes. Its implementations are invoked at their sessionCreated method in the order in which they have been declared, and at their sessionDestroyed method in reverse order.
Örnek
Şöyle yaparız
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class MyHttpSessionListener implements HttpSessionListener {

  @Override
  public void sessionCreated(HttpSessionEvent event) {
    System.out.println("session created");
  }
  @Override
  public void sessionDestroyed(HttpSessionEvent event) {
    System.out.println("session destroyed");
  }
}

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...