Hi all, I am using struts2.1.8. Here I want to handle double submission. truts2 provides TokenInterceptor. So if I submitted two times, it returns "invalid.token" as a result name. But I want to display the same page from which I have submitted twice.
Is double submission required functionality in your application?
If you want to prevent double submit problems it is better to implement the Redirect after Post pattern, see the following two links for a detailed explanation:
http://www.theserverside.com/news/1365146/Redirect-After-Post
Since you want to display the same page that you double-submitted from, you'll need to create an invalid.token
result in each of the <action>
definitions you're trying to prevent double submission from:
<action name="some-action" class="foo.Bar">
<interceptor-ref name="token"/>
<result name="success">/WEB-INF/some/action/success.jsp</result>
<result name="invalid.token">/WEB-INF/some/action/input.jsp</result>
</action>
The docs provide more info and you might also want to consider looking into the Token Session Interceptor.
Look at the TokenSessionInterceptor, which builds upon the TokenInterceptor. From the docs:
Unlike the normal token interceptor, this interceptor will attempt to provide intelligent fail-over in the event of multiple requests using the same session. That is, it will block subsequent requests until the first request is complete, and then instead of returning the invalid.token code, it will attempt to display the same response that the original, valid action invocation would have displayed if no multiple requests were submitted in the first place.