Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpSession issue with Popups

 
sreenath reddy
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
sreenath reddy
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic