You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by grati_a_lozano <gr...@panalon.com> on 2004/05/14 12:44:04 UTC
Session attributes lost when open a popup window
Hi all,
I'm working with Struts 1.1.
When open a JSP page in a popup window with JavaScript, the Session
attributes are lost.
I make a little example:
The test1.jsp put one attribute ("test1") in Session and invoke
test2.jsp in two ways:
a) When submit the form, a forward is defined to return test2.jsp
b) Using a JavaScript function
Test2.jsp only must check that the attribute "test1" exists and
display it:
That is TEST1.JSP
<SCRIPT language="javascript">
function openwindow(){
aBase='<html:rewrite
page="/test2.jsp" />';
window.open(aBase, "test2",
"200", "200");
}
</SCRIPT>
<TITLE>TEST1</TITLE>
<% request.getSession().setAttribute("test1", "hola"); %>
</HEAD>
<BODY>
<html:form action="/test1Action">
<html:text property = "texto"/>
<html:submit value="test2"/><br>
</html:form>
<a href='javascript:openwindow()'>test2</a>
</BODY>
That is TEST2.JSP
<BODY>
<logic:present name="test1">
session.test1:
<bean:write name="test1" scope="session" /><br>
</logic:present>
</BODY>
That is the piece of struts-config.xml concerned (test1Action do
nothing but returns the addecuate forward ).
<action-mappings>
<action
name="test1"
path="/test1Action"
scope="request"
type="test_struts.forms.test1Action">
<forward
name="success"
path="/test2.jsp" />
</action>
</action-mappings>
And that is the result:
If test2.jsp is invoked via the Submit button, it is open in the same
browser window and display:
session.test1: hola
If test2.jsp is invoked via the link, nothing is displayed.
I'm looking in Google and it seems that the session ID (jsession) is
lost.
To avoid that I tried to change the JavaScript code using the next:
<% String url =response.encodeURL("test2.jsp"); %>
window.open( <%=url%>,"TEST", "200", "200");
but with the same results.
My questions are:
How can I open a popup window without losing session?
Is there another way to do that using Struts tags?.
Thanks in advance and excuses for my English.
Regards.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Session attributes lost when open a popup window
Posted by Harjot Narula <ha...@induslogic.com>.
Hi
I see no reason of losing the session while opening a JSP in a new pop up
window.
Try this
<a href='/test2.jsp' target='test2' >test2</a>
or
window.open("/test2.jsp","test2");
I am pretty sure that no session variables are lost while opening a JSP in
a pop up window.
Harjot
----- Original Message -----
From: "grati_a_lozano" <gr...@panalon.com>
To: <st...@jakarta.apache.org>
Sent: Friday, May 14, 2004 4:14 PM
Subject: Session attributes lost when open a popup window
> Hi all,
>
> I'm working with Struts 1.1.
>
> When open a JSP page in a popup window with JavaScript, the Session
> attributes are lost.
>
> I make a little example:
>
> The test1.jsp put one attribute ("test1") in Session and invoke
> test2.jsp in two ways:
>
> a) When submit the form, a forward is defined to return test2.jsp
>
> b) Using a JavaScript function
>
> Test2.jsp only must check that the attribute "test1" exists and
> display it:
>
> That is TEST1.JSP
>
> <SCRIPT language="javascript">
> function openwindow(){
> aBase='<html:rewrite
> page="/test2.jsp" />';
> window.open(aBase, "test2",
> "200", "200");
> }
> </SCRIPT>
>
> <TITLE>TEST1</TITLE>
> <% request.getSession().setAttribute("test1", "hola"); %>
> </HEAD>
>
> <BODY>
> <html:form action="/test1Action">
> <html:text property = "texto"/>
> <html:submit value="test2"/><br>
> </html:form>
>
> <a href='javascript:openwindow()'>test2</a>
>
> </BODY>
>
> That is TEST2.JSP
>
> <BODY>
> <logic:present name="test1">
> session.test1:
> <bean:write name="test1" scope="session" /><br>
> </logic:present>
> </BODY>
>
>
> That is the piece of struts-config.xml concerned (test1Action do
> nothing but returns the addecuate forward ).
>
> <action-mappings>
> <action
> name="test1"
> path="/test1Action"
> scope="request"
> type="test_struts.forms.test1Action">
> <forward
> name="success"
> path="/test2.jsp" />
> </action>
> </action-mappings>
>
>
> And that is the result:
>
> If test2.jsp is invoked via the Submit button, it is open in the same
> browser window and display:
>
> session.test1: hola
>
> If test2.jsp is invoked via the link, nothing is displayed.
>
> I'm looking in Google and it seems that the session ID (jsession) is
> lost.
>
> To avoid that I tried to change the JavaScript code using the next:
> <% String url =response.encodeURL("test2.jsp"); %>
> window.open( <%=url%>,"TEST", "200", "200");
>
> but with the same results.
>
> My questions are:
> How can I open a popup window without losing session?
> Is there another way to do that using Struts tags?.
>
> Thanks in advance and excuses for my English.
>
> Regards.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Session attributes lost when open a popup window
Posted by br...@tcs.com.
Hi lozano
I had the same problem. whenever i close the pop up window the session is
lost in the parent window too. I am using JDeveloper as IDE and weblogic
to deply. Someone adviced me that this is a problem with the OC4J
contained shipped with JDeveloper. But I doubt this may also be due to
some bug in IE.
Brati Sankar Ghosh
Tata Consultancy Services
Mailto: brati.sankarghosh@tcs.com
Website: http://www.tcs.com
"grati_a_lozano" <gr...@panalon.com>
05/14/2004 04:14 PM
Please respond to
"Struts Users Mailing List" <us...@struts.apache.org>
To
struts-user@jakarta.apache.org
cc
Subject
Session attributes lost when open a popup window
Hi all,
I'm working with Struts 1.1.
When open a JSP page in a popup window with JavaScript, the Session
attributes are lost.
I make a little example:
The test1.jsp put one attribute ("test1") in Session and invoke
test2.jsp in two ways:
a) When submit the form, a forward is defined to return test2.jsp
b) Using a JavaScript function
Test2.jsp only must check that the attribute "test1" exists and
display it:
That is TEST1.JSP
<SCRIPT language="javascript">
function openwindow(){
aBase='<html:rewrite
page="/test2.jsp" />';
window.open(aBase, "test2",
"200", "200");
}
</SCRIPT>
<TITLE>TEST1</TITLE>
<% request.getSession().setAttribute("test1", "hola"); %>
</HEAD>
<BODY>
<html:form action="/test1Action">
<html:text property = "texto"/>
<html:submit value="test2"/><br>
</html:form>
<a href='javascript:openwindow()'>test2</a>
</BODY>
That is TEST2.JSP
<BODY>
<logic:present name="test1">
session.test1:
<bean:write name="test1" scope="session" /><br>
</logic:present>
</BODY>
That is the piece of struts-config.xml concerned (test1Action do
nothing but returns the addecuate forward ).
<action-mappings>
<action
name="test1"
path="/test1Action"
scope="request"
type="test_struts.forms.test1Action">
<forward
name="success"
path="/test2.jsp" />
</action>
</action-mappings>
And that is the result:
If test2.jsp is invoked via the Submit button, it is open in the same
browser window and display:
session.test1: hola
If test2.jsp is invoked via the link, nothing is displayed.
I'm looking in Google and it seems that the session ID (jsession) is
lost.
To avoid that I tried to change the JavaScript code using the next:
<% String url =response.encodeURL("test2.jsp"); %>
window.open( <%=url%>,"TEST", "200", "200");
but with the same results.
My questions are:
How can I open a popup window without losing session?
Is there another way to do that using Struts tags?.
Thanks in advance and excuses for my English.
Regards.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
ForwardSourceID:NT00008F22