aspose file tools*
The moose likes JSP and the fly likes session lost with window.open() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "session lost with window.open()" Watch "session lost with window.open()" New topic
Author

session lost with window.open()

Padraig Joseph
Greenhorn

Joined: May 07, 2002
Posts: 13
I've read the similar topic below, but my problem is slightly different in that there is no intervening servlet.
When I use window.open() to open a new window, the session object i had previously is lost.
How can I retain the session in the new window?
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
What are you opening your new window from? Is it a JSP? Or an HTML page? If it is a JSP then just use the encodeURL method to generate the new window URL.
If it is an HTML page then how is it generated? If it just a static file then I dont think you can get the session info to it, you'll have to change the page to be generated by a JSP or servlet. If it is already generated by a servlet you can jst use the encodeURL method to create the URL and place it in the generated page.
does that help? If not post some code or another explaination.


Dave
Padraig Joseph
Greenhorn

Joined: May 07, 2002
Posts: 13
Thanks, encodeURL worked...
Denes Kellner
Greenhorn

Joined: Jul 14, 2002
Posts: 2
I have the same problem with window.open() but what's even worse: i don't give any url because i load the new window's contents with document.write() methods. (Obviously, i have no chance to use encodeURL in this case ) What is the solution?
(some msdn pages said that this is an IE bug and should be worked around by turning off the "launch ie windows in a separate process" checkbox... i wonder if it's true, but is this REALLY the only way?... ask my users kindly to switch it off and think of Gates instead of me? )


-dgr-
chanoch wiggers
Author
Ranch Hand

Joined: May 24, 2001
Posts: 245
why cant you use encode URL? Althouhg you are generating the content of the page dynamically using javascript, it must be possible to write part of the javascript dynamically, like
var think = "<%=encodeURL("/")%>";
or something, that should allow you to capture the session key (there might even be a less gruesome way of doing it) so that you can use it to encode an URLs that you create dynamically with your javascript


chanoch<p><a href="http://www.amazon.com/exec/obidos/ASIN/1861007736/" target="_blank" rel="nofollow">Author of Professional Apache Tomcat</a></p>
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Hi guys... does this problem occur when I used javascript?? for example:
<A href="javascript opUp('<%=url%>')">
I have couple of pages with this javascript but I'm not sure if I run into the same problem..
I don't know what encodeURL is and what it is for...
thanks


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Denes Kellner
Greenhorn

Joined: Jul 14, 2002
Posts: 2
Originally posted by chanoch wiggers:
why cant you use encode URL? (...) like
var think = "<%=encodeURL("/")%>";
or something

Well, either you don't understand the problem or i don't see the solution... I don't believe that Explorer would act different just because of using a string-to-string function in my code.
However, i walked around the problem in the past few hours and i found that if i open a simple window when my program starts (and ask user not to close it, for a whatever reason), this solves the Whole Big Explorer 6 Problem (aka WBE6P from now on ) So this is a quick patch until ms comes out with the bugfix. Basically, the cookie problem happens when you close the LAST window that has been window.open()-ed by your site. If one of them stays, your session parameters stay too.
There are a few cases when Explorer doesn't lose the cookie but these are more like accidents. Normally it does. This is a documented bug, see http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q315713 for details. BUT DON'T THINK IT'S OKAY if you download the browseui.dll mentioned on this page - i got that 1024512 bytes long version and it does NOT solve the problem. What you really can do is 2 easy-to-follow steps: sit and wait

(any other patch or solution or workaround or whatever would be still appreciated! thx)
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Just had the same behaviour (IE 5.5), this solution was implemented in Websphere 4.0.3 but should work with the others too...
Turn on URL Rewriting, use response.encodeURL("") to add the session ID to the URL.
Does this help, or am I just confusing things at this stage?
Ryan Ekins
Greenhorn

Joined: Jan 15, 2003
Posts: 1
We have had the same problems with our popups losing the cookie from the parent window, and I have been given the task to find a solution. I'm looking for a solution, (eg. download this patch, upgrade to new service pack) not a work around. Has anyone successfully fixed this, short of reinstalling your OS? I have tried to update my browser service packs, but I still get the same behavior in the popups. I have the newest version of IE6 and it still happens. We also have an exe that we use to call a browser in our own window, and the session lost on the popup ALWAYS happens on all of our machines which leads us to believe it is a Microsoft OS problem rather than an IE problem. Any help with this would be appreciated.
Angela French
Greenhorn

Joined: Nov 21, 2003
Posts: 1
I know this is an old thread -- but I just found it while researching a problem I'm having. I'm trying to figure out if this thread is talking about the same issue.
I have an asp application. It consists of a main form page with links that open up popup windows (using javascript window.open). At the beginning of each page I have vbscript that checks to make sure session("logonID") is still there in case anyone timesout the app, or tries to enter a page without going thru logon. Fairly regularly, but not every time, when I click on a link to open a popup, the popup window doesn't not recognize my logonID. As if it is no longer part of the session. When this happens to me the only thing to do is to completely shut down my computer and bring it back up. Then it works fine. This happens on dev, test, and production. When this has happened to me, I've checked it out on a co-workers computer and it does not happen with him. The application has been in production over a year, and only two users have ever complained of the same issue (Yesterday it happened to the second user.Itwas the first time this has occured for him - I believe he is on a new laptop. He uses IE5.5. I use IE6 and my coworker uses IE6. I searched the web and found that IE5 had a bug like this that was fixed. Does this bug still exist in later versions? Is must be initatied by something because it doesn't happen all the time.
Has anybody come up with a solution to this?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: session lost with window.open()