• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Will this result from memory error/ preventing multiple request

 
Winston Liek
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jsp page with a submit button and invokes a post method via ajax. When the button is pressed, my application will do some processing on backend using spring mvc

However, when the user clicks the button continuously without waiting for my app to finish processing, another post request enters in my servlet. How can I prevent this? I think this will make my servlet result in memory space error?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happened when you tried it?
 
Winston Liek
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the controller method reexecutes after twice clicking. What i'm trying to do is tomcat should reject incoming request for the same user / session if there is existing processing in the serverside for him
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this really a problem? Can you get the browser to issue so many requests that the server actually locks up (hint: unlikely).
 
Stefan Evans
Bartender
Posts: 1807
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The issue you are dealing with is solved by using throttling/debouncing.

Instead of having the server detect multiple duplicate requests, why not prevent the user clicking the button in the first place?

http://benalman.com/projects/jquery-throttle-debounce-plugin/

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's great from a stance of not letting the user do stupid things, but in the context of the original question (over-burdening the server) isn't really necessary. The browser isn't going to be able to fire off enough multiple requests to clog the server -- unless the server can't handle simultaneous requests that number in the dozens, at most. In that case, there's a problem far beyond clueless users.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic