Double submit handling using struts tokens
843838Jan 30 2006 — edited Feb 9 2006Hi,
I am using struts token to handle double submit.
The way i have implemented is,
wrote a base Action class.
Inside the BaseAction class i have overriden the resetToken method like this,
synchronized public void resetToken(javax.servlet.http.HttpServletRequest request) {
javax.servlet.http.HttpSession session;
session = request.getSession(false);
if (session == null) {
return;
}
session.removeAttribute("org.apache.struts.action.TOKEN");
saveToken(request);
}
I m calling saveToken inside resetToken for new pages.
So how it would work is first time in my action i would call saveToken which would set token in my jsp page and then in respective actions i would check if isTokenValid(),
and then call resetToken so that i would clear the old on and set the new one for the new jsp page.
Is that the right way i m doing it ?
Please suggest me if there is better way to handle it.
Thanks
Abbyss