Action saveToken and isTokenValid into struts

Action saveToken and isTokenValid into struts

Previous Home Next

 

saveToken and istokenValid is the helper methods which enable you to add advanced functionality toyour struts application.saveToken and istokenValid both is to make sure that a form has not submitted twice.

 
In struts applicaion,transaction tokens to ensure that a form is not submitted twice.A transaction is unique string that is generated.The token is submitted with the form tag.

saveToken :-This method generates a unique token and saves it token in the session under the key org.apache.struts.action.TOKEN. 

isTokenvalid :- This method return true or false value.This method return 'true' if the token stored in the session with that submitted from the form  both are equals otherwise return false. 

why we are using this concept :-

We send the request to the server for first time it is going to accept it and if we are sending multiple requests as like that then from second request onwards it stops executing the code.So only first request only it works.
In bank applications if we send multiple times then improper action occurs and we may get unrelated problems.


Previous Home Next