File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Restrict user Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Restrict user" Watch "Restrict user" New topic
Author

Restrict user

Nithish Yalamanchili
Greenhorn

Joined: Aug 16, 2007
Posts: 24
Hi All

I need a solution for this problem. Generally in any application when user logins from a browser, at the same time if the same user logins from different machine or browser, then it should display you are logged in some where ,please logout from tht. My code is in struts and JSP, please tell me the solution.

Nithish
vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
Have a application level hashmap, when user logged in, add it to the hashmap, when user logged out remove it from hashmap.whenever user is logging in check with hashmap whether user is already present in map,if so deny him.

There may be chance user has simply close the browser without logging off.

This is not optimized solution.
John Melton
Ranch Hand

Joined: Aug 17, 2004
Posts: 49
A very similar solution I have used in the past is to store this information in the database. This allows for tracking of user sessions over a period of time. However, it is an extra DB call. It seems to work fairly well though. The point that Vidya makes is also true. You would have to write a session timeout listener to remove the user from either the hash map or the database in order to make sure they could login again. The timeout listener would be called whenever the session times out (configured in web.xml)
Hope this helps.


[url]www.jtmelton.com[/url]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Restrict user