Hi, before knowing about tokens, I have implemented a way to deal with the "refresh of a POST form" problem. Now that I know that tokens exist, I can't really use them for several reasons, but mainly because it adds a field in the <form> which modifies my current form validation with javascript. Here is what I have done in my ActionBase class, that every Action I use derives from :
protected void setDBFlag(Object o, HttpServletRequest request) { synchronized(session.getId()){ request.getSession(false).setAttribute( Parametres.DB_FLAG + o, Parametres.CHECKBOX_TRUE); } } protected void clearDBFlag(Object o, HttpServletRequest request) { synchronized(session.getId()){ request.getSession(false).removeAttribute( Parametres.DB_FLAG + o); } } protected boolean checkDBFlag(Object o, HttpServletRequest request) { synchronized(session.getId()){ return ( request.getSession(false).getAttribute( Parametres.DB_FLAG + o) != null); } } These methods should be called from the class below this way : public class MyAction extends ActionBase{ .... ... protected ActionForward executeUpdate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { if ("GET".equalsIgnoreCase(request.getMethod())) { setDBFlag(this, request); this.processBeforeUpdate(mapping, form, request, response); return mapping.findForward(EDIT); } else { HttpSession session = request.getSession(false); ListResultCsv resultats = (ListResultCsv) (session.getAttribute(attTable)); if(checkDBFlag(this, request)){ //update DB processUpdate(...,form); updateBeanConteneur(); clearDBFlag(this,request); }} } ..... }//end of class As you can see I'm putting a flag on the session. This flag name is actually function of the name of the Action instance itself (this). The idea is to put the flag to true while preparing the form, then when the form is submitted, I check if the flag is true then I do the updates and set the flag to false. So when a user presses refresh, the form is not submitted 2 times. The problem with this solution is that I must use the same Action to prepare and submit the Form, but it's the case most of the times. I was wondering if the solution I chose looks OK in a multi-user application. I know that each user has its own Action instance, so it should not be a problem, but at the same time, looking at Struts' implementation of the tokens which is more complicated, I think there might be some issues with my approach. Thanks in advance for the feedback! ________________________________ Raphaël di Cicco