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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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(x xx, 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("Ex pires", 0);
%>
Anything alarming you?
in doGet,
HttpSession thisSession = aRequest.getSession();
then to store data in session
thisSession.setAttribute(x
to retrive from session,
httpsession.getAttribute("
This is what I have in jsp regarding cache.
<%
response.setHeader("Cache-
response.setHeader("Pragma
response.setDateHeader("Ex
%>
Anything alarming you?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.personaliz ation.sess iontrackin g.SessionA pplication Parameters @1be
session tracking epm app data : com.ibm.servlet.personaliz ation.sess iontrackin g.SessionT rackingEPM Applicatio nData@4024
enable epm : true
non-serializable app specific session data : {}
serializable app specific session data : {LogonUser=User@78b, OrderAsUser=User@4e38, TransactionObject=OrderTra nsactionDa ta@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.
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.personaliz
session tracking epm app data : com.ibm.servlet.personaliz
enable epm : true
non-serializable app specific session data : {}
serializable app specific session data : {LogonUser=User@78b, OrderAsUser=User@4e38, TransactionObject=OrderTra
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
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.co okie);
</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>
<HTML>
Session ID: <%= session.getId() %> <p>
Cookies:
<script>
document.write(document.co
</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>
ASKER
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, 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
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?
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
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
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.