Solved

Getting the session from parent to child window in JSP - (using struts)

Posted on 2003-10-28
6
2,213 Views
Last Modified: 2007-12-19
Hi All,

I am developing a JSP application using struts.

In my application, from my main browser window am opening a child pop up window using javascript.

The problem that am facing is, am not able to get the session object of the parent window in child window. It is creating a new session object in child window.

Code:
for opening the child window in java script-

win = window.open("GfaProjectWeb/commoncsp.do?method=openWorkItemAction&workobjectno="+workObjNum, 'childCSP');


In Action form,
      public ActionForward openWorkItemAction(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)
        throws ServletException
      {

HttpSession session = request.getSession();


Here the the session object that is created is having different session ID.


Note: 1. If I open the child page in same browser window(ActionForward), I am able to get the session object. When i open in new window, am facing the problem.

Kindly let me know how to tackle this issue.

Thanks and regards,
Balaji
0
Comment
Question by:balaji_p
  • 3
  • 2
6 Comments
 
LVL 14

Expert Comment

by:kennethxu
ID: 9647224
1. make sure you are NOT using IDE intergrated browser, use IE or Netscape.
2. make sure the page you are opening in child window is under same servlet context as the page in parent window.
3. enable cookie on your browser OR encode your url as:
win = window.open("<%=response.encodeURL("GfaProjectWeb/commoncsp.do")%>?method=openWorkItemAction&workobjectno="+workObjNum, 'childCSP');
0
 
LVL 3

Expert Comment

by:applekanna
ID: 9668045
Balaji ,
I think this should as it did for me ,
Since you are using JSP you can use the JSESSIONID varaible

In parent window send it as

win = window.open("GfaProjectWeb/commoncsp.do?method=openWorkItemAction&workobjectno="+workObjNum, 'childCSP'&JSESSIONID= <%=session.getId()%> )

at the child window

you can do
HttpSession session = request.getSession(false);

This shouuld work!!!

Do mail me if you need more help.

Cheers!

ps. Kennethxu - correct me if i am wrong
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 50 total points
ID: 9668255
>>ps. Kennethxu - correct me if i am wrong
:-)
I'm not sure if that'll work, but at least not all servlet container use JSESSIONID for url rewrite session tracking. so always use response.encodeURL()
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:applekanna
ID: 9668274
>>so always use response.encodeURL()
Thx for the tip :)


I am using Apache Tomcat and this worked for me ;) from a JSP so worth a shot
0
 

Author Comment

by:balaji_p
ID: 9668779
Hi kennethxu,

Thanks a lot... It worked. Actually the problem was using browser integrated with IDE(Point 1). I am using WSAD and it is integrated with IE. But when i tried it using new instance of browser, I was able to pass the session object without any problem.

And since I am able to get the session object, now there is no need for me to pass the session ID as a part of the querystring.....

Once again...thankx for ur immediate reply...which helped me to save a lot of effort....

And applekanna... Thankx for ur suggestion...

Balaji
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9673209
my pleasure and glad to know your problem is resolved.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
change size of out.write buffer 1 87
lessBy10  challenge 15 92
struts exact match support 3 51
Why my table column Id is not passed to java object? 4 28
A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
The new Gmail Phishing Scam going around is surprising even the savviest of users with its sophisticated techniques. This attack comes as a nightmare trifecta for email filtering services; sent from a familiar contact, using authentic tone and verbi…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now