• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Restrict user

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic