Link to home
Start Free TrialLog in
Avatar of prabudoss
prabudoss

asked on

Session handling in Pop up jsps

Working in Java/Jsp arch. I have two levels of Pop ups (invoked using showModalDialog() method of javascript) coming up from a parent browser window. Should I handle anything special for keeping all these modal dialogs to be in same session? Because, during debug, the session id is differing when new pop up is opened and the data stored by Parent session is not accessible from child. Is that there something I'm missing?
Avatar of allahabad
allahabad

Are you using url rewrite to maintain session ?
If you are using url rewrite to maintain session, your session will be different for the new window, however, if you use cookies, same session  will be maintained by the server when new window in opened.
ASKER CERTIFIED SOLUTION
Avatar of kennethxu
kennethxu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of prabudoss

ASKER

I'm amateur in this area. I'm using session like this

in doGet,
HttpSession thisSession = aRequest.getSession();

then to store data in session
thisSession.setAttribute(xxx, data);

to retrive from session,
httpsession.getAttribute("xxx");


This is what I have in jsp regarding cache.
<%
     
     response.setHeader("Cache-Control", "no-Cache");
     response.setHeader("Pragma", "No-cache");
     response.setDateHeader("Expires", 0);
%>

Anything alarming you?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I basically store this session object in a map in a helper class and use that helper class to talk to session object in rest of the application. I step through the code and I got that session id is differing and also my values whatever I stored in Parent is missing. Below is the values I got in one of the Parent

SessionObject=
Session Object Internals:
id : X3BQETYAAAAANQFILOHH2EY
hashCode : 14371
create time : Wed Mar 05 23:07:54 GMT+05:30 2003
last access : Wed Mar 05 23:08:24 GMT+05:30 2003
max inactive interval : 1800
user name : anonymous
valid session : true
new session : false
session active : true
overflowed : false
session application parameters : com.ibm.servlet.personalization.sessiontracking.SessionApplicationParameters@1be
session tracking epm app data : com.ibm.servlet.personalization.sessiontracking.SessionTrackingEPMApplicationData@4024
enable epm : true
non-serializable app specific session data : {}
serializable app specific session data : {LogonUser=User@78b, OrderAsUser=User@4e38, TransactionObject=OrderTransactionData@49a5}

session data list : Session Data List ->  id : X3BQETYAAAAANQFILOHH2EY next : LRU prev : MRU


and when I'm in first level of Pop up and got session object and got same id "X3BQETYAAAAANQFILOHH2EY" as in parent but when I opened second level of Pop up (using showModalDialog()) this id was differing and I could not see any app specific data.
the second level popup is a page in the same application?

CJ
could you please try this test jsp and let us know the result? it will show if you get the same session or not.

<HTML>
Session ID: <%= session.getId() %> <p>
Cookies:
<script>
document.write(document.cookie);
</script>
<p>
<%
    if( request.getParameter( "test" ) == null ) {
         session.setAttribute( "test", "Test string in session" );
    } else {
         out.println( "Attribute: " + session.getAttribute( "test" ) + "<p>" );
    }
%>
<a href="?test" target="new">new window</a>
</HTML>
I tried to use the test jsp. This problem is somewhat not consistently occuring. Sometimes I could get the same session across the children Pop ups. But few times the session id varies. May be VAJ test env has something to with this. Any idea of this?
>> May be VAJ test env has something to with this

Yes, I have heard similar problem been reported for other tools as well as VAJ.

Try to use IE or NS connect to real server.
yes use a regular browser.

a popup in VAJ maybe opening a new browser session (new instance of the browser) rather than a new browser window (within the same session)

CJ
do you still have this problem when you use IE?
Avatar of girionis
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Split points between kennethxu and cheekycj

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer