Double submit handling using struts tokens

Hi,

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

[1026 byte] By [Abbyssa] at [2007-10-2 10:57:25]
# 1
You can use isTokenValid(request, true) which will automatically call resetToken() after checking the token.Izida
Izidaa at 2007-7-13 3:23:42 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...