Local database reading edition

How to enforce one logon in your web application?

Reconstructed from database records, not a captured original forum layout. Dates and display names are retained as recorded; timezone and real-world identity are not inferred. Historical advice, contact details and offers are not current. Original markup is shown as inert text.

Forum index · Java - Tips Of The Day

Opening post

Asha · 2001-02-14 16:12:38

What you need to do is to maintain a list of users currently logged into the application in the servlet context. (You can basically store a vector containing the users logged in within the 'application' implicit variable if you are using JSP) Of course, the challenge here is to recognize when the user logs out and to update the vector within the servlet context accordingly. You will also need to take into account the situation where the user may forget to explicitly log out and consequently undergoes a session timeout. A way to handle this is to place a wrapper object which implements the HttpSessionBindingListener interface into the session upon login. You can then remove the username from the vector in the servlet context within the valueUnbound() method of the wrapper object. This is possible as the method is automatically invoked via a callback by the servlet container if the session times out or is explicitly invalidated. You should also provide the necessary synchronization code within your JSP or servlet whenever you access any object within the servlet context Asha Balasubramanyan http://www.ammu.org

Source notes

MyCommunity/nandighosha.org.zip!/forum/tools/snitz_forums_2000.mdb
Table: FORUM_TOPICS + FORUM_REPLY · record IDs: 32