Struts 2
  1. Struts 2
  2. WW-3415

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

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.11.1
    • Fix Version/s: 2.3.18
    • Component/s: Core Interceptors
    • Labels:
      None
    • Flags:
      Important

      Description

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

      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();
      params.remove(tokenName);
      params.remove(TokenHelper.TOKEN_NAME_FIELD);

      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
      invocation.getProxy().setExecuteResult(false);

      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.

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            Sachin Tandon
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development