You can use below code in action.
In loading of previous page
ActionContext.getContext().getSession().put(Globals.TRANSACTION_TOKEN_KEY, "123");
In jsp page
<s:hidden name="token" value="123"/>
And in action class of form submission
Map<String,Object> session = ActionContext.getContext().getSession();
if(getToken().toString().equalsIgnoreCase(session.get(Globals.TRANSACTION_TOKEN_KEY).toString())){
System.out.println("request is handled");
//reset the token
//perform update
session.put(Globals.TRANSACTION_TOKEN_KEY, "124");
}
In both jsp pages use this
< %
response.setHeader("Cache-Control", "no-cache, no-store");
response.setDateHeader("Expires", 0);
response.setHeader("Vary", "*");
% >
The simple way is
if (session.getAttribute("recordInsertedSuccessfully") == null )
{
//update records
//after inserting into the database we should do :
session.putAttribute("recordInsertedSuccessfully","true");
} else {
//case of form re-submission
}
Your problem is you are again calling the method which is setting session variable to 123.
make another method runinspect2()
, copy paste code from runinspect()
but remove line from runinspect2()
which is setting session variable to 123 which is following line
ActionContext.getContext().getSession().put(Globals.TRANSACTION_TOKEN_KEY, "123");
and call runinspect2()
in update()
method it is simple