Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to handle a scenario where many users are viewing the same form with one having a write access and others read access?

Posted on 2004-04-16
5
Medium Priority
?
171 Views
Last Modified: 2010-04-01
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,
Deepak
0
Comment
Question by:anudeep20
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 92

Accepted Solution

by:
objects earned 172 total points
ID: 10839938
instead of giving read acces, do a check when the update is made to see whether an update has occurred since the user loaded the order.
this would require u to store the last update time for each order.
0
 
LVL 35

Assisted Solution

by:TimYates
TimYates earned 164 total points
ID: 10840133
Or, I usually have a "lock for writing" button which a user has to click before they edit a value like this

So everyone is in read-only mode, then user A clicks "lock for editing", I save user A's id in the lock table (so now no-one else can lock the form)

User A then saves the form, and that unlocks it.

You can store a lock time with the lock, so that locks time-out after about 10 minutes or so :-)

Tim
0
 
LVL 16

Assisted Solution

by:warturtle
warturtle earned 164 total points
ID: 10841752
Hi,

You could essentially write a database trigger that checks for updates, and gets the username, whosoever is writing to it. Then put a lock( blocking any data,  being written/read from another user, while the first user is updating the values). As soon as the work is done, then the lock can be removed and that can help keep a check on the user, trying to write to it or read from it.

Regards,

Warturtle
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question