I am facing a problem. This must be a very common problem in Web-based application. I think someone must be having an answer for the following problem:
Web-based application has been built using (MVC architecture). This application retrieves an order from a database and display it on browser using JSP page.
Now the problem is, say a user A retrieves an order "100" from the database and makes changes in the order and also saves changes into the database. Say another user B retrieves the same order "100" from the database at the same time when user A is modifying the order. As the user "A" has already opened up the order "100" first, then only user A should have the write access i.e. user B should have only the read access to order "100".
Initially I thought of a solution in which by creating an Bean object (which would have the scope application) which takes care of all the orders which are getting displayed at any point of time. So, in the above mentioned example as user A has opened up the order "100" first, it's entry would be populated into this bean object along with the session ID. Now, when user B tries to open up the order "100", as bean object has an entry for this order already in this bean object, user B would get only the read access. Whenever a person logs out or the Session ID is no more valid, that particular order number would be deleted from this bean object.
But there is a problem in the above approach. The problem comes only when a user does not log out from the application but simply closes the browser. Then as long as that Session ID is valid that order number would be there in the object and consequently no one can have a write access to that order till that session expires. In our application session time out is around 30 minutes which cannot be reduced.
Please suggest me some other solution.
Thanks in advance,