Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3415

Issues with Token session interceptor - Blank page is returned in case of double submission


    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s:
    • Fix Version/s: 2.3.20
    • Component/s: Core Interceptors
    • Labels:
    • Flags:


      Blank page is returned in case of double submission. I am using struts version -

      I have extendend TokenSessionStoreInterceptor class in my code and not changed any functionality. Following is how my class looks like

      public class MyClass extends TokenSessionStoreInterceptor{

      • Default Serial Version Id
        private static final long serialVersionUID = 1L;

      protected String handleInvalidToken(ActionInvocation invocation) throws Exception {
      ActionContext ac = invocation.getInvocationContext();

      HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
      HttpServletResponse response = (HttpServletResponse) ac.get(ServletActionContext.HTTP_RESPONSE);
      String tokenName = TokenHelper.getTokenName();
      String token = TokenHelper.getToken(tokenName);

      if ((tokenName != null) && (token != null)) {
      Map params = ac.getParameters();

      ActionInvocation savedInvocation = InvocationSessionStore.loadInvocation(tokenName, token);

      if (savedInvocation != null) {
      // set the valuestack to the request scope
      ValueStack stack = savedInvocation.getStack();
      Map context = stack.getContext();
      request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);

      ActionContext savedContext = savedInvocation.getInvocationContext();
      savedContext.getContextMap().put(ServletActionContext.HTTP_REQUEST, request);
      savedContext.getContextMap().put(ServletActionContext.HTTP_RESPONSE, response);
      Result result = savedInvocation.getResult();

      if ((result != null) && (savedInvocation.getProxy().getExecuteResult())) {
      synchronized (context)

      { result.execute(savedInvocation); }


      // turn off execution of this invocations result

      return savedInvocation.getResultCode();

      return INVALID_TOKEN_CODE;

      protected String handleValidToken(ActionInvocation invocation) throws Exception

      { // we know the token name and token must be there String key = TokenHelper.getTokenName(); String token = TokenHelper.getToken(key); InvocationSessionStore.storeInvocation(key, token, invocation); return invocation.invoke(); }


      Now, whenever I do a double submission for a functionality like search (which gets loads of data from the database), previously saved invocation does not complete and savedInvocation.getResultCode() returns null (inside handleInvalidToken method). Due to which I receive a blank page.

      Whenever I do a debug(from eclipse) on handleInvalidToken method, savedInvocation.getResultCode() value changes from null to "success" as I wait inside the method for sometime.

      I have also put in savedInvocation.isExecuted() in this handleInvalidToken method and noticed that its value changes from false to true if I wait on the line of code for some time.




            • Assignee:
              lukaszlenart Lukasz Lenart
              sachin.tandon Sachin Tandon
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created: