Two Laptop Bag*
The moose likes JSP and the fly likes HttpSession issue with Popups Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "HttpSession issue with Popups" Watch "HttpSession issue with Popups" New topic
Author

HttpSession issue with Popups

sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi all

I have an application which has many popups . But i am encountering a weird scenario while working with this

I logged in to my system (which uses a HttpSession) and then i opened a popup . I submitted the data in the popup and operation in the popup is expected to take some time . In the mean while i logged out(the HttpSession is invalidated on logout) the user in the parent window and logged in again with the same user name.

After the user has logged in again, by this time operation in popup is complete which is supposed to return some response in the popup but now session expired message comes up(as i have used some tag similar to check logon which checks the user data in session and takes him to the page if the session doesn't contain any data) which is fine

But to the surprise , clicking in the parent window also shows the same session expired (i hadn't done any logout ....)

After lot of analysis i found that as soon as i logout for the first time , tomcat is creating a new session which is assigned to the popup window and the same is getting applied to the parent window also even though a seperate HttpSession was created for this window ........now after this request.getSession() in the parent window is giving me the newly created session in the popup which doesn't have any user data

Can any one let me know how to avoid this ??
Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
It sounds like you just shouldn't be logging out while trying to do something. If I understand correctly, you said that your popup is waiting for something from the server, but then you're invalidating the session that the server is using and then expecting that session to be there...why how could you invalidate the session being used and then expect to still be able to use it after it's destroyed?
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi stephen

Yah u got it correctly . May be i should not log out if the user is performing some operation but how can i get to know this while invalidating ??

U understood my problem clearly , i am invalidating (logging out) the session when its in use ....and its obvious that tomcat will create immediately new session after the one is invalidated for that browser

but one thing which surprises me is , when i logout the first user and login again ....at the point when login is successful , i observed the session object let say A . Later after that popup operation is over and when it comes back the session in the pop up is replacing the parent windows.i mean calling request.getSession() in the parent window is giving another session object B rather its expected to give A as the session .......

Hope u got the problem ..i think it has something to do with session mechanism of tomcat
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

sreenath, JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. Additionally, such shortcuts may confound automated translation tools that patrons of the Ranch may be making use of.

I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not using such abbreviations.

Please read this for more information.

thanks,
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Sreenath, could you please make it a bit simple and clear. And please elaborate what are you trying to do. It might be helpful in understanding your problem.
Thanks.
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi adeel

The problem is it can't be explained in brief as its tough to understand . Anyways let me try ....

I have popup in my application and the HttpSession object assocaited with it and the parent window is always picking the HttpSessio of the popup .......

I am sure this will not make things clear better you can go through my first post .i had written in detail the scenario
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Popup windows share the same session cookie space as the opener window.
This is normal. The two windows SHOULD be part of the same session.

Why would you want them to have separate sessions?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi ben

I do agree that popup should take the same session space as the opener but when i logged out parent window ie nothing but invalidating the existing session , and logged in again a new HttpSession objevt is created but at this moment the popup is not having the same newly created session object (which the parent window has)

I wanted to know how i can prevent this
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If you the user logs off from the main window, why not close all the child windows?
Logging off, generally, means your done.
Why would you need child windows hanging around?
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi ben

Really i like ur idea of closing the popups .but is there any way to get to close the pop up windows from the main window ??
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Yes, you can store the handle for the popup in a JS variable.
This will allow you to call window.close on the popup.

The guys in HTML/Javascript could probably give you sample code faster than I could.

See if you can get the bar-keep to move this thread down there.
 
wood burning stoves
 
subject: HttpSession issue with Popups
 
Similar Threads
Check if popup window is already open from parent window?
How to maintain session in Both Parent window and child window
Using ModalDialogs instead of Window.open for popups
Modal dialog for a popup
issue with session on restart of server