• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Prevent multiple submit...

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is an entry in the javaranch struts faq that addresses this:

http://faq.javaranch.com/view?StrutsFaq

This is a rather pathetic faq that only contains one entry, and it happens to address this topic.
 
The problems of the world fade way as you eat a piece of pie. This tiny ad has never known problems:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic