Class WebSessionFunctions


  • public class WebSessionFunctions
    extends java.lang.Object
    Helper class for session handling.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void clearCurrentHttpServletRequest()
      Unassigns the current thread from its current http servlet request.
      static void clearSession​(javax.servlet.http.HttpSession session)  
      static javax.servlet.http.HttpServletRequest getCurrentHttpServletRequest()
      Returns the http servlet request associated with the current thread, or null if no request had been stored.
      static javax.servlet.http.HttpSession getCurrentHttpSession()
      Returns the http session associated with the current thread.
      static JaloSession getSession​(java.lang.String cookiename, javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean skipSystemInitTest)
      returns a JaloSession object
      static JaloSession getSession​(java.lang.String cookiename, javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Class sessionClass, boolean skipSystemInitTest)
      returns a JaloSession object
      static JaloSession getSession​(java.util.Map connProp, java.lang.String cookiename, javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      returns a JaloSession object
      static JaloSession getSession​(java.util.Map _connProp, java.lang.String cookiename, javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Class sessionClass)
      returns a JaloSession object
      static JaloSession getSession​(javax.servlet.http.HttpServletRequest request)
      returns a JaloSession object.
      static JaloSession getSession​(javax.servlet.http.HttpServletRequest request, boolean skipSystemInitTest)
      returns a JaloSession object.
      static void invalidateSession​(javax.servlet.http.HttpSession session)
      Closes the HTTP and JaloSession (if one is present under key 'jalosession').
      static boolean isStaleRequest​(javax.servlet.http.HttpServletRequest request)
      Allows you to check if request is part of the stale session.
      static void markRequestAsStale​(javax.servlet.http.HttpServletRequest request)
      Allows you to mark request as part of the stale session.
      static void setCurrentHttpServletRequest​(javax.servlet.http.HttpServletRequest request)
      Assigns the given http servlet request to this thread.
      static JaloSession tryGetJaloSession​(javax.servlet.http.HttpSession session)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WebSessionFunctions

        public WebSessionFunctions()
    • Method Detail

      • isStaleRequest

        public static boolean isStaleRequest​(javax.servlet.http.HttpServletRequest request)
        Allows you to check if request is part of the stale session.
        Parameters:
        request - request to check.
        Returns:
        true if request is part of the stale session, false otherwise.
      • markRequestAsStale

        public static void markRequestAsStale​(javax.servlet.http.HttpServletRequest request)
        Allows you to mark request as part of the stale session.
        Parameters:
        request - request to be marked.
      • getCurrentHttpSession

        public static javax.servlet.http.HttpSession getCurrentHttpSession()
        Returns the http session associated with the current thread. This is based on the current http servlet request being assigned to this thread. Therefore the method returns null if no request had been assigned.
        See Also:
        getCurrentHttpServletRequest(), setCurrentHttpServletRequest(HttpServletRequest)
      • invalidateSession

        public static final void invalidateSession​(javax.servlet.http.HttpSession session)
        Closes the HTTP and JaloSession (if one is present under key 'jalosession').
      • clearSession

        public static final void clearSession​(javax.servlet.http.HttpSession session)
      • tryGetJaloSession

        public static final JaloSession tryGetJaloSession​(javax.servlet.http.HttpSession session)
      • getSession

        public static final JaloSession getSession​(javax.servlet.http.HttpServletRequest request)
                                            throws JaloConnectException,
                                                   JaloSystemNotInitializedException
        returns a JaloSession object.

        If you don't want to use cookies and are connecting to the local server, this is the preferred method to get or create a JaloSession object.

        Parameters:
        request - the HttpServletRequest object
        Returns:
        the JaloSession
        Throws:
        JaloConnectException - in case of a connection error
        JaloSystemNotInitializedException - in case the connection was successful but the system not yet initialized
      • getSession

        public static final JaloSession getSession​(java.util.Map connProp,
                                                   java.lang.String cookiename,
                                                   javax.servlet.http.HttpSession session,
                                                   javax.servlet.http.HttpServletRequest request,
                                                   javax.servlet.http.HttpServletResponse response)
                                            throws JaloSystemNotInitializedException
        returns a JaloSession object

        1. if a JaloSession is stored inside of the HttpSession (key 'jalosession'), this JaloSession is returned.
        2. if cookies are not used, or no cookie was found, an anonymous session is created, put in the HttpSession and returned
        3. if cookies are used and a cookie was found, then we try to 'reactivate' the customer stored inside the cookie, if this was not successful, an anonymous session is created.
        Parameters:
        connProp - deprecated, use always NULL

        cookiename - if null, no cookies are used, otherwise this is the cookiename that should be used.
        session - the HttpSession object
        request - the HttpServletRequest object
        response - the HttpServletRespone object
        Throws:
        JaloSystemNotInitializedException - in case the connection was successful but the system not yet initialized
      • getSession

        public static final JaloSession getSession​(java.util.Map _connProp,
                                                   java.lang.String cookiename,
                                                   javax.servlet.http.HttpSession session,
                                                   javax.servlet.http.HttpServletRequest request,
                                                   javax.servlet.http.HttpServletResponse response,
                                                   java.lang.Class sessionClass)
                                            throws JaloSystemNotInitializedException
        returns a JaloSession object

        1. if a JaloSession is stored inside of the HttpSession (key 'jalosession'), this JaloSession is returned.
        2. if cookies are not used, or no cookie was found, an anonymous session is created, put in the HttpSession and returned
        3. if cookies are used and a cookie was found, then we try to 'reactivate' the customer stored inside the cookie, if this was not successful, an anonymous session is created.
        Parameters:
        _connProp - Deprecated, use always NULL

        cookiename - if null, no cookies are used, otherwise this is the cookiename that should be used.
        session - the HttpSession object
        request - the HttpServletRequest object
        response - the HttpServletRespone object
        sessionClass - the jalo class of the new session, if null JaloSession will be taken
        Throws:
        JaloSystemNotInitializedException - in case the connection was successful but the system not yet initialized
      • getSession

        public static final JaloSession getSession​(javax.servlet.http.HttpServletRequest request,
                                                   boolean skipSystemInitTest)
                                            throws JaloConnectException,
                                                   JaloSystemNotInitializedException
        returns a JaloSession object.

        If you don't want to use cookies and are connecting to the local server, this is the preferred method to get or create a JaloSession object.

        Parameters:
        request - the HttpServletRequest object
        skipSystemInitTest - is true, this metod will not execute a db statement in order to determine if the system is initialize
        Returns:
        the JaloSession
        Throws:
        JaloConnectException - in case of a connection error
        JaloSystemNotInitializedException - in case the connection was successful but the system not yet initialized
      • getSession

        public static final JaloSession getSession​(java.lang.String cookiename,
                                                   javax.servlet.http.HttpSession session,
                                                   javax.servlet.http.HttpServletRequest request,
                                                   javax.servlet.http.HttpServletResponse response,
                                                   boolean skipSystemInitTest)
                                            throws JaloSystemNotInitializedException
        returns a JaloSession object

        1. if a JaloSession is stored inside of the HttpSession (key 'jalosession'), this JaloSession is returned.
        2. if cookies are not used, or no cookie was found, an anonymous session is created, put in the HttpSession and returned
        3. if cookies are used and a cookie was found, then we try to 'reactivate' the customer stored inside the cookie, if this was not successful, an anonymous session is created.
        Parameters:
        cookiename - if null, no cookies are used, otherwise this is the cookiename that should be used.
        session - the HttpSession object
        request - the HttpServletRequest object
        response - the HttpServletRespone object
        skipSystemInitTest - is true, this metod will not execute a db statement in order to determine if the system is initialize
        Throws:
        JaloSystemNotInitializedException - in case the connection was successful but the system not yet initialized
      • getSession

        public static final JaloSession getSession​(java.lang.String cookiename,
                                                   javax.servlet.http.HttpSession session,
                                                   javax.servlet.http.HttpServletRequest request,
                                                   javax.servlet.http.HttpServletResponse response,
                                                   java.lang.Class sessionClass,
                                                   boolean skipSystemInitTest)
                                            throws JaloSystemNotInitializedException
        returns a JaloSession object

        1. if a JaloSession is stored inside of the HttpSession (key 'jalosession'), this JaloSession is returned.
        2. if cookies are not used, or no cookie was found, an anonymous session is created, put in the HttpSession and returned
        3. if cookies are used and a cookie was found, then we try to 'reactivate' the customer stored inside the cookie, if this was not successful, an anonymous session is created.
        Parameters:
        cookiename - if null, no cookies are used, otherwise this is the cookiename that should be used.
        session - the HttpSession object
        request - the HttpServletRequest object
        response - the HttpServletRespone object
        sessionClass - the jalo class of the new session, if null JaloSession will be taken
        skipSystemInitTest - is true, this metod will not execute a db statement in order to determine if the system is initialize
        Throws:
        JaloSystemNotInitializedException - in case the connection was successful but the system not yet initialized