Page should be accessed by one user at a time
Hi friends,
I have a new requirement where webpage should be accessed by one user at a time.Suppose if one user is using the page ,the other user should not be having the privilage to access tht page.NOw how to go about..If possibel pls help me with the code..
Thanks in advance..
Waiting for ur suggestion.
[332 byte] By [
gania] at [2007-11-27 10:10:25]

# 1
Well you need some sort of locking on it, and logic when you try going to this page. Some sort of front end controller on it.
if (pageNotInUse){
acquireLockForPage();
forwardToPage;
}
else {
forwardToPageBusyMessage();
}
Detecting when a user first requests a page is easy enough.
How do you detect when they leave it?
What happens if they close their browser when they are on that page? How does it release the lock?
You will probably have to tie into the session listener so that if someone times out you can release their lock.
# 6
You can set a boolean variable to do this.
Also use static variables in the application (not the JSP) so that it has a scope of all requests.
So you can ask the system, is a user inside, and you can retrieve a boolean value.
If someone goes in there for the first time, set the boolean to true.
But you need to figure out how you can check when he is not in that site anymore, and then set it to false.
I think the best way is to use login of some sort. Then it is much easier to check.
You can create a login bean with username and password and use a database or file to store the password.