I am using Struts2 framework, my problem is
If user log-in into system and clicked some action lets say ACTION1
, flow will go to action class and executes some method, return appropriate result.
He may visit some of the web pages, and again clicked ACTION1
.
As long as he is in the same session, now the control should not go that particular method but the result should be same as previous results.
How can we achieve this?
You can try a tokenSession
interceptor.
This interceptor builds off of the Token
Interceptor, providing
advanced logic for handling invalid tokens. 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.
It will prevent from double submit the same action or reuse the same token that you provide with s:token
tag.
Description
Stop double-submission of forms.
The token tag is used to help with the "double click" submission
problem. It is needed if you are using the TokenInterceptor
or the
TokenSessionInterceptor
. The s:token
tag merely places a hidden
element that contains the unique token.
Place the tag inside your form and you never get back in submitting the same form twice. Token session interceptor will try to handle invalid token for you by returning the same response like in first case.