Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlets and synchronized

 
Paul Richards
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem where the user may press the submit button button and submit the form to a servlet.
Within the servlet a call to a AS400 stored procedure is made, which in several circumstances may take time to execute.
Whilst this execution is taking place the user may press the submit button again thus possibly calling the AS400 stored procedure agian before the previous one has finished.
This is a situation I need to prevent.
Would putting a
synchronized (request.getSession){
.....as400 call....
}
prevent this problem?
cheers for any advice.
Paul
 
Sunetra Saha
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think you can do this by synchronizing. Why not just set a flag in the servlet before calling the procedure and reset it after the procedure finishes? Then just a check on the flag can prevent multiple procedure calls even if the submit button is pressed repeatedly.
Or maybe you can try javascript to prevent resubmission of the form.
 
Aman Rustogi
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Sunitra. A workaround solution would be to either set a timer [using javascript] to - ummm say sumthing 'round 2 mins. before again submitting the request/calling the servlet which calls the procedure. It would thus prevent the user from submitting the form till the time set expires.
cheers
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic