Class SessionHolder


  • public class SessionHolder
    extends Object
    Holds the session associated with the current request. This utility class was added to work around an incompatibility problem with some Servlet containers (JBoss Web, Tomcat). In these containers, HttpServletRequest.getSession(boolean) cannot be used within HttpSessionListener#sessionCreated(HttpSession) method invocation is the created session is not made available. As a result either null is returned or a new session is created (possibly causing an endless loop). This utility class receives an HttpSession once it is created and holds it until the request is destroyed / session is invalidated.
    Author:
    Jozef Hartinger
    • Method Detail

      • requestInitialized

        public static void requestInitialized​(jakarta.servlet.http.HttpServletRequest request)
      • sessionCreated

        public static void sessionCreated​(jakarta.servlet.http.HttpSession session)
      • getSessionIfExists

        public static jakarta.servlet.http.HttpSession getSessionIfExists()
      • getSession

        public static jakarta.servlet.http.HttpSession getSession​(jakarta.servlet.http.HttpServletRequest request,
                                                                  boolean create)
      • clear

        public static void clear()