Announcement Announcement Module
Collapse
No announcement yet.
Handling expired session gracefully Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Anyone? Please?

    Comment


    • #3
      I have exactly the same requirement.

      I too would appreciate any ideas.

      Comment


      • #4
        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}

        Comment


        • #5
          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

          Comment


          • #6
            Can you please tell me how did you manage logout in this

            Comment


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

              Comment


              • #8
                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);
                        }

                Comment


                • #9
                  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;
                      }
                  }

                  Comment


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

                    Comment


                    • #11
                      FYI, JIRA opened here https://jira.springsource.org/browse/SWF-1598

                      Comment

                      Working...
                      X