*
The moose likes Servlets and the fly likes Multiple tabs share sessions so data in going into inconsistent state? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Multiple tabs share sessions so data in going into inconsistent state?" Watch "Multiple tabs share sessions so data in going into inconsistent state?" New topic
Author

Multiple tabs share sessions so data in going into inconsistent state?

shyam ji gautam
Ranch Hand

Joined: Sep 17, 2011
Posts: 48
Dear all

i face a problem when one men which name is arun has two userid: arun1
and arun2

he use two tabs in same browser and login first with arun1 and now second time with arun2 so arun1 think he is doing something transaction but in databses this entry is goes on name of arun2 (latest login )

because browser shres the same sessionid with different tabs . i know this fact


i want that when second user (arun2) will be login then arun1 will automatically goes to logout and login screen will be coming for arun1

how i implement these because these feature si have seen in gmail also .

thanks
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3060
    
  38

You can implement it in many different ways. In one approach, you can use ajax and poll the status for the user ID, which is currently being displayed. Implement a Servlet that checks whether the given user ID belongs to the current session. If it isn't, send an ajax response stating that, and your JavaScripts should redirect the user to the login screen. In another approach, you can store a cookie that contains the current user ID. Using JavaScripts, read that cookie in regular basis and check whether the current user ID is equivalent to what exists in the cookie. When it isn't, that's the time to redirect to the login page.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple tabs share sessions so data in going into inconsistent state?