An optimal solution for resolving double form submission problem using Struts:
DispatchStrutsAction
--------------------
package com.myapp.struts;
public class DispatchStrutsAction extends DispatchAction {
private final static String LOGINSUCCESS = "loginsuccess";
private final static String LOGINPAGE = "loginpage";
public ActionForward beforeLogin(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
this.saveToken(request);//save token before showing Login.jsp
return mapping.findForward(LOGINPAGE);
}
public ActionForward login(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
if(this.isTokenValid(request)){
resetToken(request);
}else if(!this.isTokenValid(request)){
System.out.println("Page Resubmit");
}
return mapping.findForward(LOGINSUCCESS);
}
}
Sunday, November 8, 2009
Handling double form submission problem with Struts
Subscribe to:
Post Comments (Atom)
Dear Techie,
ReplyDeletePlease explain what is double form submit problem.
Is it about clicking the submit button twice by mistake?
exactly!
ReplyDelete