Issues with Token session interceptor - Blank page is returned in case of
double submission
-------------------------------------------------------------------------------------------
Key: WW-3415
URL: https://issues.apache.org/jira/browse/WW-3415
Project: Struts 2
Issue Type: Bug
Components: Core Interceptors
Affects Versions: 2.0.11.1
Reporter: Sachin Tandon
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.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.