views:

775

answers:

1

Hi,

I have several portlets in my application. If I open a url using window.open() method, the session id changes and causes an error in other portlets. If I don't open this url, everything works fine. But once this new window is opened, the session is cleared and the rest of the portlets throws an exception since some values are missing. In the address bar of the browser I typed in javascript:alert(document.cookie); to see the JSESSIONID. It remains constant throughout the page and changes when I click the link that launches a new url in new window. I used IE8.

Any suggestions to maintain the session state in IE would be greatly appreciated.

A: 

What URL are you passing to window.open()? An easy way to get IE 8 to maintain the JSESSIONID in the popup would be to use a relative URL in the call to window.open() in the portlet markup. The critical thing is that the domain name remain exactly the same. Here's an example of a button with window.open() in the onclick event:

<button onclick="javascript:window.open('/wps/portal')">Home Page</button>

I'm using Websphere Portal, so '/wps/portal' just links to the home page.

Also, what do you intend to be the target of the popup window? A different portal page with the same session?

Update: Given that the target of the window.open() is an independent web application hosted on the same domain...

The portal server and the application server hosting the web application have independent sessions, but they both use a cookie called JSESSIONID by default. The first time you access the web application, the application server overwrites the portal's cookie, causing every subsequent request to the portal to have the wrong session id. When this happened to me, my solution was to configure the portal to name its session cookie something else (e.g. PORTALSESSIONID) so the two do not conflict.

cc1001
Thanks for the response... I'm passing the complete url as a parameter to the open() method, but the domain name is exactly the same as of the parent. I'll try your suggestion also. The target is not a portal page, but a different web application hosted under the same domain, for example if the main domain is example.com, I open example.com/app/index.jsp
whoopy_whale
I think there may be a naming conflict with the JSESSIONID cookie. I've updated this answer with some additional details.
cc1001