This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Prevent Multiple Submits Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Prevent Multiple Submits" Watch "Prevent Multiple Submits" New topic
Author

Prevent Multiple Submits

Balakrishnan Viswanathan
Greenhorn

Joined: Mar 03, 2008
Posts: 23
Hi.
I have an application, where in I have multipler servers (used for load-balancing). And the data is maintained in oracle and is pretty huge. As the application is vast, there are many performance-intensive transactions that take even 10 minutes to complete. Recently, we have been having issues where the same operation has been committed by multiple-users. Example,

a.) First user logs in and submits the process
b.) while the transaction is running, another user trys to do the same thing unknowing the fact that it is already running.

I can try preventing this submit, using javascript or even session. But, this being a multi-server architecture, session variable that is present in one server is not visible to the other one.

Can you please suggest me one best way to prevent this problem?

Thanks
Bala


SCJP 1.4, SCWCD 1.5
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874



I can try preventing this submit, using javascript or even session. But, this being a multi-server architecture, session variable that is present in one server is not visible to the other one.


Bala,

I dont understand how one user is so tightly coupled to the other user. Is it clustered servers ? in that case session migration is there and session variable is visible to other servers , but its costly and hence you got to minimize the variables in session.

Javascript ? Do you mean disabling submit . thats not the proper solution for this.



Is that expected behavior ? Check if you use any instance variables , which is shared among threads , hence needs to be synchronized.
Naresh Narayana
Greenhorn

Joined: Aug 17, 2006
Posts: 5
If it takes that long to complete request, better use a queue for the requests and process each one as they complete.
Hope it helps.
Balakrishnan Viswanathan
Greenhorn

Joined: Mar 03, 2008
Posts: 23
Thanks for the reply.

Actually yes, some times even the user who submitted first assumes that the process is not running correctly and re-submits it again. Or some other user submits the process.
Am not sure whether usage of synchronized will help here and nor the synchronized threads.

Actually, am thinking about a way to load the first user submit details in a xml and when second user submits, use JAXB to identify whether it is present and if present do not do it again.

Any suggestions or improvements?
 
jQuery in Action, 2nd edition
 
subject: Prevent Multiple Submits
 
Similar Threads
Session attributes are thread safe
Most proper definition of a Session
Preventing doubleclicks
Disabling multiple clicks by the user
PageContext.getSession vs req.getSession vs Session in JSP