Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2003-10-28
6
Medium Priority
?
2,386 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Files go missing when using DFS (Distributed File System) Replication and how to recover them and fix it.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

730 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