This is the code snippet I am using
if (isTokenValid(request))
{
logger.debug("Add data to owner table");
System.out.println("Add data to owner table");
j=db.addRole(menuform);
if (j == 1)
menuform.reset(mapping, request);
else
request.setAttribute("recordModifyCount", 0);
message.add("recordmodify", new ActionMessage("record.insert", j));
}
else
{
System.out.println("Token not valid Add owner");
logger.debug("Token not valid Add owner");
//message.add("recordmodify", new ActionMessage("record.insert", 0));
//forward=mapping.findForward("searchAllMenuPage");
}
This is called when I click on add button
The first time I click It works perfectly but the second and afterwards It goes in else block i.e.”Token not valid Add owner”
Please help me why it goes in else block.
You need to call
saveToken()first and Struts framework will generate atoken/keyin request/session.Next time when you make a request, you can check whether this token is valid or not.Once you called isTokenValid, you need to callresetToken()method as well.Preventing multiple click