Struts has a token feature that puts a single-use token on a form to prevent duplicate submits. Redirecting after post prevents duplicate submissions using the "back" button but will not prevent a duplicate post if a user submits more than once in rapid succession.
Typically when a Struts action is going to forward to a page that will post information the action will call Action.saveToken(HttpServletRequest). Struts will then automatically add the token to the form when the <html:form> tag is rendered.
When the post occurs the action should perform an Action.isValidToken(HttpServletRequest, true) to verify and invalidate the token. Any succeeding posts with the token will be cause isValidToken() to return false.
Above answer was rated as good by the following members: pradeepkmr18, batswon
Tokens are used to check for invalid path for by the uer: 1) if the user presses back button and submits the same page 2)or if the user refreshes the page which will result to the resubmit of the previous action and might lead to unstabality..
to solve the abv probs we use tokens 1) in previous action type saveTokens(HttpServletreuest) 2) in current action check for duplication bu if(!isValidToken())
Another important usage of tokens is to trap an event when the user hits the Submit button twice. Tokens allows to prevent duplicate processing for such a request.
Struts has a token feature that puts a single-use token on a form to prevent duplicate submits. Redirecting after post prevents duplicate submissions using the back button but will not prevent a duplicate post if a user submits more than once in rapid succession.
Typically when a Struts action is going to forward to a page that will post information the action will call Action.saveToken(HttpServletRequest). Struts will then automatically add the token to the form when the <html:form> tag is rendered.
When the post occurs the action should perform an Action.isValidToken(HttpServletRequest true) to verify and invalidate the token. Any succeeding posts with the token will be cause isValidToken() to return false.
Tokens are used to prevent multi click problem in struts.
In Action class method at the begining of the code need to call the saveToken() that generates an unique identifier for the "request url" and stotes it in the session and also in the jsp as hidden param to which the request forwarded to. The hidden param in jsp is automatically created by struts if we use <html:form> tag
isTokenValid() compares the users session token with the token given as a request parameter (either through hidden form field (form tag) or through additional parameter on a url (link tag)).