This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
If the user connects to your application from two different browsers, whether they are on the same machine or not, then your application container will automatically assign two different sessions. You don't have to do anything to tell it to do that.
Joined: Dec 21, 2012
hey paul, i know that but in that case container will treat the user as two different users. but in my case the user is same . my question will be clear through this example
suppose i have my gmail id and i have opened it on my machine . now my friend want to see my gmail at the same time, so i provide him user and password. so at the same instance he also logs into gmail from his own machine. i want to implement this scenario only using servlets and jsp
Okay, now that you have asked your actual question, then we can answer it.
The solution has very little to do with sessions. You need the user(s) to log in to your application so that they are all accessing the same data. Note that the data used to log in is in a database somewhere, not in the session. Likewise the data they are accessing and sharing is not in the session. The only thing the session is useful for is keeping track of the users' logged-in status.
Joined: Dec 21, 2012
Thanks paul, Now the second constraint is that i want a user to restrict for N logins that is if a user , at an instant logs from two machines then it is ok. but i want to restrict him just for the two logins that is if he tries to login from the third machine he should not be able to login. He can only login from third machine only-if one of the current login session is closed.
Okay... remember what I said about shared data in the database being the way to control things? You put some shared data in the database to keep track of how many times a user has signed on. Increment it when the user signs on, decrement it when the user signs off.
That's the simple description of the process. In real life you need to take care of more things than that, but it's the general idea.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com