Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Handling expired session gracefully

  1. #1

    Question Handling expired session gracefully

    I've searched, so I apologize if I'm missing the answer somewhere.

    When the HttpSession has expired and the user re-submits a page in the flow, he/she is sent back to the beginning of the flow. All I want to add to this behavior is a message explaining why it occurred. "You were inactive, so you have been restarted..."

    What's the easiest/best-practice way to do this?

    Similar question for replaced executions or snapshots. Global on-exception transition for FlowExecutionRestorationFailureException with EL to put a message on some scope?

    Thanks for assistance.

  2. #2

    Default

    Anyone? Please?

  3. #3
    Join Date
    Jan 2007
    Posts
    8

    Default

    I have exactly the same requirement.

    I too would appreciate any ideas.

  4. #4

    Default

    Is there even a place where I could check for session.isNew()? By the time I hit my JSP (under Tiles), it is no longer new :-(

    ${pageContext.session.new}

  5. #5

    Default

    i have got a solution to this problem.
    We can use a javascript (Countdown.js)
    that takes in ${pageContext.session.maxInactiveInterval}
    and after time ends it shows the message

  6. #6

    Default

    Can you please tell me how did you manage logout in this

  7. #7

    Default

    Quote Originally Posted by breaux View Post
    ${pageContext.session.new}
    That wouldn't work anyway, duh. Wouldn't be able to distinguish new-new from timed-out-new.

  8. #8

    Default Used a filter

    All I could come up with for now is a simple filter that redirects to a separate page. I imagine I could have gotten something on a scope the flow would understand, but because of the SWF redirect behavior, it was going to take multiple steps to do it, so I settled for this.

    Basically:

    Code:
            if (request.getRequestedSessionId() != null && !request.isRequestedSessionIdValid())
            {
                log.info("Expired Session ID: " + request.getRequestedSessionId());
                response.sendRedirect("sessionExpired");
            }
            else
            {
                chain.doFilter(request, response);
            }

  9. #9

    Default Or an Interceptor

    Code:
    public class SessionExpiredInterceptor extends HandlerInterceptorAdapter
    {
        private String redirectLocation = "sessionExpired";
    
        @Override
        public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
            Object handler) throws Exception
        {
            if (request.getRequestedSessionId() != null && !request.isRequestedSessionIdValid())
            {
                response.sendRedirect(redirectLocation);
                return false;
            }
    
            return true;
        }
    
        public String getRedirectLocation()
        {
            return redirectLocation;
        }
    
        public void setRedirectLocation(String redirectLocation)
        {
            this.redirectLocation = redirectLocation;
        }
    }

  10. #10

    Default

    FYI also posted to Stack Overflow. No answers there so far, except my own conclusions already reflected in this thread.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •