Duplicate form submission results in saving duplicate data in database unnecessary. If you don’t want to save duplicate data in database, you need to prevent duplicate request to save in database. Action form get old request and save request object again in html form, and if user reload the page, it will save again and again in database.
Duplicate submission can be occur by refresh of page by user, pressing back button in browser, virus in user machine which resubmit form on every request.
Way to prevent duplicate request in Struts.
1. By handling isTokenValid() method of struts.
2. By handling clearing request object.
We are talking about clearing request object and creating new request for form.
<action input="input" path="/user_path" type="com.test.action.UserAction" name="UserFormName" scope="request" validate="true"> <forward name="failure" path="/home.jsp" /> <forward name="input" path="/home.jsp" /> <forward name="success" path="/home.jsp" redirect="true" /> </action>
Use redirect true attribute when form is saved successfully in database. This will generate new request and clear previous object for that form.
If you reload page with right click option, you will find your page’s data is not saving in database, and duplicate submits is stopped in struts by simply adding a redirect attribute



Link to Us