• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Prevent Multiple Page Refresh

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,

I have a struts web application that is giving me a problems. I recently came across a problem where if the user hit F5 multiple times it would cause an out of memory SQL exception. I found the issue and resolved the situation, however I want to ensure that this won't happen again even if something gets done incorrectly. I have been told that its possible to ignore the refresh if someone hits it multiple times in a short period. However, I can't seem to find any good documentation on how to do anything but disable the F5 button in IE and Firefox. Can someone help me with resources? Or Confirm that it simply isn't possible. I see a lot of mixed answers some indicating it is possible and then others that its not. I am under the impression that it can kind of sorta be done in certain browsers under specific situations, but nothing fool proof. Just trying to exhaust my resources before I give up on this one.
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I dont know if it is possible to ignore refresh. But why not store a session attribute indicating no of times refreshed in a particular interval. If it exceeds threshold we can block the access. What wrong with this strategy?
 
Sheriff
Posts: 67597
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The solution is not to try and ignore F5, or any other actions, on the client. That way lies madness and frustration.

The solution is to be able to deal with it on the server. Always.
 
John Lark
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry to break this open again after a month. My first attempt was to simply decrease the number of SQL connections made to the database, but if the user hammers the refresh they can still reproduce the issue. I haven't been able to figure a good way to handle it on the client side, most of the internet seems to be struggling with resubmitting information through a form my problem comes when loading the page with information from the database. Gaurav if you had a link to some documentation that would better explain your suggestion I would appreciate it. I would like to do like Source Forge does, if you hit the refresh too many times too fast they deny you access to the server. Can that be handled by the application? Tomcat? Is that going to require a third party app?
 
Gaurav Wadhwani
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not use the counter approach. Increase it till a threshold is reached within a small interval and if so then block access.

The JSP for it would be something like this
 
John Lark
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay so that works, I implemented something similar but instead of using a max interval I am storing a current time value then using a series of if statements to determine if my refresh cycle has expired. Seems to be working.

Thanks guys!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic