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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to