tags:

views:

253

answers:

2

Hi i am having the html page in my web application. The page is locked by a client and unlocked by the same client. if the client forgets to unlock or close the browser, press back button on the page, and other links the page will locked always and cannot be unlocked. i need to unlock the page in the above cases if he forget to unlock Thanks

+1  A: 

Specify a timeout for the lock. Since http is stateless you can't observe the client the "normal way".

EDIT: I'd protocol activity per client/lock on serverside by setting/observing some bool flag. A TimerTask is observing the flag periodically, setting the flag to false if it's true and kills the lock if it's false.

Kai
how can i do that
@abc: It will entirely depend on how you're locking to start with.
Jon Skeet
+1  A: 

I would suggest that you consider a design more appropriate to the operating characteristics of your environment.

Instead of locking and unlocking in separate transactions (which is what you have now), consider a form of optimistic locking - basically, allow anyone to have access to the data, but if they submit a modification after another user has submitted a modification to the same data, reject and give the user an opportunity to make their change again.

Having a user/client explicitly lock and unlock is easy to code, but hard to use (and we do all care about out users' experience!) Cheerio.

Kevin Day