Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Prevent multiple submit...  RSS feed

Azuritul Wu
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hope this is the right place for this question.

This problem is confusing me for a period of time. It is primarily about the double submit problem.

The scenario is like the following:
My web app has a page that list all the report(in html button) the user can click. After the button is clicked, another window will pop out. In the popped out window, the user can choose the report's date range. After that, the user clicks the submit button in the popped out window, then the request is processed and an excel report is generated.

I use struts and iBatis in this web app.
So the flow of report processing is:
choose date range -> to ActionForm -> forward to the HttpServlet and process and output the xls report.

And here is the problem.

The window that let the user choose date range is still on the screen after the date is choosed and submitted. By this time, if the user click the submit button(in date choosing window) many times, the request will also be sent multiple times. Thus the content of the report generated will simply be wrong.

So, what should I do to prevent the user from double(or even more) submit?
Or, how do I tell the server to just ignore the second request if the first request is still in processing.

I tried Strut's TokenProcessor. But it seems not suitable for my problem.
Yes, I can ask the server to forward to different page after receiving the second request, the report will still be processed, but will be discarded afterwards(because the app forwards the second request to another page).
And it would just throw a "connection reset by peer" exception.

Any suggestion or advice is welcomed and appreciated.
Thank you.
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is an entry in the javaranch struts faq that addresses this:

This is a rather pathetic faq that only contains one entry, and it happens to address this topic.
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!