-
Avoid duplicate submiting the form (6 messages)
- Posted by: NithisKumar V
- Posted on: January 03 2007 09:50 EST
How to eliminate the duplicate submision of form in struts application??Threaded Messages (6)
- Re: Avoid duplicate submiting the form by Srinivas Reddy Bijjam on January 04 2007 05:47 EST
- Re: Avoid duplicate submiting the form by Yasoda Supraja on January 04 2007 21:07 EST
- Re: Avoid duplicate submiting the form by Dmitry Namiot on January 05 2007 06:53 EST
-
Re: Avoid duplicate submiting the form by Arman Galustyan on January 06 2007 03:48 EST
- Avoid duplicate submiting the form in discussions by Yasoda Supraja on January 12 2007 02:46 EST
- Re: Avoid duplicate submiting the form by Yasoda Supraja on January 04 2007 21:07 EST
- Still coding forms by hand? by Aziz Mwondha on June 28 2007 07:23 EDT
-
Re: Avoid duplicate submiting the form[ Go to top ]
- Posted by: Srinivas Reddy Bijjam
- Posted on: January 04 2007 05:47 EST
- in response to NithisKumar V
Handle duplicate form submission The problem of duplicate form submission arises when a user clicks the Submit button more than once before the response is sent back or when a client accesses a view by returning to a previously bookmarked page. This may result in inconsistent transactions and must be avoided. In our sample application, a similar problem will arise if the customer clicks the submit button more than once while submitting the purchase order. In Struts this problem can be handled by using the saveToken() and isTokenValid() methods of Action class. saveToken() method creates a token (a unique string) and saves that in the user's current session, while isTokenValid() checks if the token stored in the user's current session is the same as that was passed as the request parameter. To do this the JSP has to be loaded through an Action. Before loading the JSP call saveToken() to save the token in the user session. When the form is submitted, check the token against that in the session by calling isTokenValid(), as shown in the following code snippet: Example: Using saveToken() and isTokenValid() public class PurchaseOrderAction extends DispatchAction { public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try { //save the token saveToken(request) // rest of the code for loading the form } catch(Exception ex){//exception} } public ActionForward submitOrder(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try { // check the token. Proceed only if token is valid if(isTokenValid(request,true)) { //implement order submit functionality here } else { return mapping.findForward("failure"); } } catch(Exception ex){//exception} } } -
Re: Avoid duplicate submiting the form[ Go to top ]
- Posted by: Yasoda Supraja
- Posted on: January 04 2007 21:07 EST
- in response to Srinivas Reddy Bijjam
I tried stopping user from double subbmission thru ,saveToken(),isTokenValid(), Disabling browser's back button and making a server side check to throw exception when user tries to double submit. Still there are some cases, where user is skipping all these checks and double submission is still happening. Any more suggestions? -
Re: Avoid duplicate submiting the form[ Go to top ]
- Posted by: Dmitry Namiot
- Posted on: January 05 2007 06:53 EST
- in response to Yasoda Supraja
There is a component in Coldtags suite: http://www.servletsuite.com/servlets/pformtag.htm -
Re: Avoid duplicate submiting the form[ Go to top ]
- Posted by: Arman Galustyan
- Posted on: January 06 2007 15:48 EST
- in response to Yasoda Supraja
Try to implement it by your self (creating random key in session and remove it when first submit arrives). do u use cluster servers? -
Avoid duplicate submiting the form in discussions[ Go to top ]
- Posted by: Yasoda Supraja
- Posted on: January 12 2007 02:46 EST
- in response to Arman Galustyan
Thanks for reply. Yes we are using cluster servers. It will be gr8! if you let me know, how it is going to effect double submission issue. -
Still coding forms by hand?[ Go to top ]
- Posted by: Aziz Mwondha
- Posted on: June 28 2007 07:23 EDT
- in response to NithisKumar V
Most of the tips you receive will probably fix the problem but my slogan would be to get rid of the coding completely (the form itself and the handling of the posted request, that is). Have you tried a dedicated forms generation tool like Formular? I have, and I have not to worry about coding the handling of forms any more. Try looking around for other tools that do the same. For me, Formular (http://redeye.no) works fine and I never have to build the HTML myself either.