Showing posts with label web application. Show all posts
Showing posts with label web application. Show all posts

Monday, January 16, 2012

Way to Prevent Duplicate Request from Form in J2EE applications - 3

To fix duplicate form submission issue, you essentially need to implement the Synchroniser Token pattern.

This Synchroniser Token pattern is a common technique as follows:

  • Your application generates a unique token (based upon date, time and session id maybe) with each request or submits from the browser and embeds it in each HTML page returned to the browser as a hidden field.
  • When the user hits a submit button, at the server you check that the token in the page matches the token on the server.
  • If it does, you carry on.
  • If it doesn't, you don't accept the submitted data (you either fail or just show the user the last page with an error/warning).
  • Once the token is checked you immediately create a new unique token.

Now, if the same page is submitted again (by pressing the refresh button) or an old page is submitted (by the user pressing Back) the tokens will no longer match, as the server token was changed, so you can reject the submission.


-Happy Programming,

-NjN

Tuesday, June 14, 2011

Way to Prevent Duplicate Request from Form in J2EE applications -2

Guys,

Here is the another solution to prevent duplicate form submission issue in web applications irrespective of the framework implementation.

Can you please try with the below code and update me in comments?

In JSP, we can have java script method during onsubmit like below.


And our java script implementation would be like below. submitForm method return true only very first time and form will be submitted. The same will be true for the sub sequent requests. Hope this will solve our issue.

//Global variable
var submitFlag = 1;

//Submit form method
function submitForm(form) {
if ( submitFlag == 1 ) {

submitFlag = 2;
return true;

} else {
return false;

}
}


Thanks,

-Nanjundan Chinnasamy

Way to Prevent Duplicate Request from Form in J2EE applications -1

Way to Prevent Duplicate Request from Form:

Here is the common and widely used mechanism used to preventing duplication form submission from a j2ee application. Ie, disabling the submit button during on click event. Example here is ICICI bank Internet banking application.

Though this is simple and a reasonable approach if we have a single submit button within a form, this may not work if we have more than one submit buttons in a form.

Are you looking for any other simple strategy to prevent duplication form submission from client side? Follow the next blog.

Cheers,
-Nanjundan Chinnasamy

Pega Decisioning Consultant - Mission Test Quiz & Answers

The Pega Certified Decisioning Consultant (PCDC) certification is for professionals participating in the design and development of a Pega ...