You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Byju P.Nair" <bp...@india.coas.com> on 2001/10/04 07:33:21 UTC

Session Problems

Hi,

Tomcat is creating 2 different sessions when another browser 
window is opened from a main window. For instance, i have an 
application, in which the first jsp page sends a request to a servlet 
which inturn places a session object using 
request.getSession().putValue("name1","value1");

The servlet then dispatches the request to another jsp page, which 
opens another jsp page in a new dependent window with the js call,

window.open("/sqlplus/ShowScript.jsp",'wmSelectBaseClass','depe
ndent=yes,width=700,height=380,left=210,top=240');

In ShowScript.jsp window, a new session is created thereby it is 
not able to get access to name1 session object stored in the 
original session. 

I didn't find any such problems when using jswdk. As also it is not 
related to browser as i tested it in both IE and Netscape.

Could anyone please help me out to ensure only one session is 
created for all browser windows opened from the main window.

With Best Regards,

Byju P.Nair
Software Engineer,
Coas India,174,Road No. 72,
Prasashan Nagar,Jubilee Hills,
Hyderabad, India

Re: Session Problems

Posted by Marc Ponschab <po...@isys-software.de>.
Byju P.Nair wrote:
> Having 
> suppressed the cookie usage, do i have to explicitly use URL 
> rewriting by using response.encodeURL(...) to encode the 
> sessionID?

Yes, shure.

Marc

>>See server.xml:
>>
>><!-- Session interceptor will extract the session id from cookies and
>>      deal with URL rewriting ( by fixing the URL ).  If you wish to
>>      suppress the use of cookies for session identifiers, change the
>>      "noCookies" attribute to "true"
>>   -->
>><RequestInterceptor
>>     className="org.apache.tomcat.request.SessionInterceptor"
>>     noCookies="true" />
>>
>>>>>Hi,
>>>>>
>>>>>Tomcat is creating 2 different sessions when another browser 
>>>>>window is opened from a main window. For instance, i have an 
>>>>>application, in which the first jsp page sends a request to a servlet 
>>>>>which inturn places a session object using 
>>>>>request.getSession().putValue("name1","value1");
>>>>>
>>>>>The servlet then dispatches the request to another jsp page, which 
>>>>>opens another jsp page in a new dependent window with the js call,
>>>>>
>>>>>window.open("/sqlplus/ShowScript.jsp",'wmSelectBaseClass','depe
>>>>>ndent=yes,width=700,height=380,left=210,top=240');
>>>>>
>>>>>
>>>>Does:
>>>>
>>>>HttpServletResponse.encodeURL("/sqlplus/ShowScript.jsp") 
>>>>
>>>>help?  This should encode the session id into the URL.
>>>>(But if the browser has cookies enabled maybe it wont)
>>>>


Re: Session Problems

Posted by "Byju P.Nair" <bp...@india.coas.com>.
I did exactly as mentioned below, but it is helping the issue. Having 
suppressed the cookie usage, do i have to explicitly use URL 
rewriting by using response.encodeURL(...) to encode the 
sessionID?


> 
> See server.xml:
> 
> <!-- Session interceptor will extract the session id from cookies and
>       deal with URL rewriting ( by fixing the URL ).  If you wish to
>       suppress the use of cookies for session identifiers, change the
>       "noCookies" attribute to "true"
>    -->
> <RequestInterceptor
>      className="org.apache.tomcat.request.SessionInterceptor"
>      noCookies="true" />
> 
> >>>Hi,
> >>>
> >>>Tomcat is creating 2 different sessions when another browser 
> >>>window is opened from a main window. For instance, i have an 
> >>>application, in which the first jsp page sends a request to a servlet 
> >>>which inturn places a session object using 
> >>>request.getSession().putValue("name1","value1");
> >>>
> >>>The servlet then dispatches the request to another jsp page, which 
> >>>opens another jsp page in a new dependent window with the js call,
> >>>
> >>>window.open("/sqlplus/ShowScript.jsp",'wmSelectBaseClass','depe
> >>>ndent=yes,width=700,height=380,left=210,top=240');
> >>>
> >>Does:
> >>
> >> HttpServletResponse.encodeURL("/sqlplus/ShowScript.jsp") 
> >>
> >>help?  This should encode the session id into the URL.
> >>(But if the browser has cookies enabled maybe it wont)
> 


Byju P.Nair
Software Engineer,
Coas India,174,Road No. 72,
Prasashan Nagar,Jubilee Hills,
Hyderabad, India

Re: Session Problems

Posted by Marc Ponschab <po...@isys-software.de>.
Hi,


Byju P.Nair wrote:
> Yes Simon, you are right. Since the browser has cookie enabled, 
> the above statement doesn't encode the sessionID into URL :-(

See server.xml:

<!-- Session interceptor will extract the session id from cookies and
      deal with URL rewriting ( by fixing the URL ).  If you wish to
      suppress the use of cookies for session identifiers, change the
      "noCookies" attribute to "true"
   -->
<RequestInterceptor
     className="org.apache.tomcat.request.SessionInterceptor"
     noCookies="true" />

>>>Hi,
>>>
>>>Tomcat is creating 2 different sessions when another browser 
>>>window is opened from a main window. For instance, i have an 
>>>application, in which the first jsp page sends a request to a servlet 
>>>which inturn places a session object using 
>>>request.getSession().putValue("name1","value1");
>>>
>>>The servlet then dispatches the request to another jsp page, which 
>>>opens another jsp page in a new dependent window with the js call,
>>>
>>>window.open("/sqlplus/ShowScript.jsp",'wmSelectBaseClass','depe
>>>ndent=yes,width=700,height=380,left=210,top=240');
>>>
>>Does:
>>
>> HttpServletResponse.encodeURL("/sqlplus/ShowScript.jsp") 
>>
>>help?  This should encode the session id into the URL.
>>(But if the browser has cookies enabled maybe it wont)


## Keystore Keytool problem!

Posted by Sam <is...@ms45.hinet.net>.
Hi all,
I try to make CA keystore file,

==
Enter keystore password:  changit
keytool error: KeyPairGenerator not available
==

What is the message mean?
thanks all!



Re: Session Problems

Posted by "Byju P.Nair" <bp...@india.coas.com>.
Yes Simon, you are right. Since the browser has cookie enabled, 
the above statement doesn't encode the sessionID into URL :-(


> 
> > Hi,
> > 
> > Tomcat is creating 2 different sessions when another browser 
> > window is opened from a main window. For instance, i have an 
> > application, in which the first jsp page sends a request to a servlet 
> > which inturn places a session object using 
> > request.getSession().putValue("name1","value1");
> > 
> > The servlet then dispatches the request to another jsp page, which 
> > opens another jsp page in a new dependent window with the js call,
> > 
> > window.open("/sqlplus/ShowScript.jsp",'wmSelectBaseClass','depe
> > ndent=yes,width=700,height=380,left=210,top=240');
> 
> Does:
> 
>  HttpServletResponse.encodeURL("/sqlplus/ShowScript.jsp") 
> 
> help?  This should encode the session id into the URL.
> (But if the browser has cookies enabled maybe it wont)
> 
> 
> > 
> > In ShowScript.jsp window, a new session is created thereby it is 
> > not able to get access to name1 session object stored in the 
> > original session. 
> > 
> > I didn't find any such problems when using jswdk. As also it is not 
> > related to browser as i tested it in both IE and Netscape.
> > 
> > Could anyone please help me out to ensure only one session is 
> > created for all browser windows opened from the main window.
> > 
> > With Best Regards,
> > 
> > Byju P.Nair
> > Software Engineer,
> > Coas India,174,Road No. 72,
> > Prasashan Nagar,Jubilee Hills,
> > Hyderabad, India
> > 
> 


Byju P.Nair
Software Engineer,
Coas India,174,Road No. 72,
Prasashan Nagar,Jubilee Hills,
Hyderabad, India

Re: Session Problems

Posted by simon <si...@lexues.co.jp>.
----- Original Message ----- 
From: "Byju P.Nair" <bp...@india.coas.com>
To: <to...@jakarta.apache.org>
Sent: Thursday, October 04, 2001 2:33 PM
Subject: Session Problems


> Hi,
> 
> Tomcat is creating 2 different sessions when another browser 
> window is opened from a main window. For instance, i have an 
> application, in which the first jsp page sends a request to a servlet 
> which inturn places a session object using 
> request.getSession().putValue("name1","value1");
> 
> The servlet then dispatches the request to another jsp page, which 
> opens another jsp page in a new dependent window with the js call,
> 
> window.open("/sqlplus/ShowScript.jsp",'wmSelectBaseClass','depe
> ndent=yes,width=700,height=380,left=210,top=240');

Does:

 HttpServletResponse.encodeURL("/sqlplus/ShowScript.jsp") 

help?  This should encode the session id into the URL.
(But if the browser has cookies enabled maybe it wont)


> 
> In ShowScript.jsp window, a new session is created thereby it is 
> not able to get access to name1 session object stored in the 
> original session. 
> 
> I didn't find any such problems when using jswdk. As also it is not 
> related to browser as i tested it in both IE and Netscape.
> 
> Could anyone please help me out to ensure only one session is 
> created for all browser windows opened from the main window.
> 
> With Best Regards,
> 
> Byju P.Nair
> Software Engineer,
> Coas India,174,Road No. 72,
> Prasashan Nagar,Jubilee Hills,
> Hyderabad, India
> 


Re: Session Problems

Posted by Marc Ponschab <po...@isys-software.de>.
Hi,

Byju P.Nair wrote:
> Tomcat is creating 2 different sessions when another browser 
> window is opened from a main window.

Try to send the Request via the target-Attribute (A or FORM) to the new 
Window, you can open a customized window with onclick.

Example:

<a onClick="getArticleWindow();"
    href="blabla.jsp"
    target="articleWindow">
   link
</a>

var articleWindow = null;
function getArticleWindow()
{
     if (!articleWindow || articleWindow.closed)
     {
         articleWindow = window.open("/void.html",
                                     "articleWindow",
 
"status=0,toolbar=yes,scrollbars=yes,resizable=yes,width=640,height=480");
     }
     if (articleWindow) articleWindow.focus();
}

Marc


Re: Session Problems

Posted by Marco Schmalz <ma...@schess.ch>.
> request.getSession().putValue("name1","value1");


btw, the putValue()-method is deprecated since servlet2.2
you should use setAttribute(String key, Object value) instead.
have a look at the javadoc.

marco



Re: Session Problems

Posted by Manu KY <ma...@yahoo.com>.
Hi Byju,
i had played with this in Tomcat and got similar results.
i opened multiple browser windows without acknowledging the session.
after 4 windows , the browser started to send the cookie info to the 
server( i cant explain this behavior. )

what i suggest is get the client to acknowledge the session joining before 
doing some other processing on server side.

Manu
>Hi,
>
>Tomcat is creating 2 different sessions when another browser
>window is opened from a main window. For instance, i have an
>application, in which the first jsp page sends a request to a servlet
>which inturn places a session object using
>request.getSession().putValue("name1","value1");
>
>The servlet then dispatches the request to another jsp page, which
>opens another jsp page in a new dependent window with the js call,
>
>window.open("/sqlplus/ShowScript.jsp",'wmSelectBaseClass','depe
>ndent=yes,width=700,height=380,left=210,top=240');
>
>In ShowScript.jsp window, a new session is created thereby it is
>not able to get access to name1 session object stored in the
>original session.
>
>I didn't find any such problems when using jswdk. As also it is not
>related to browser as i tested it in both IE and Netscape.
>
>Could anyone please help me out to ensure only one session is
>created for all browser windows opened from the main window.
>
>With Best Regards,
>
>Byju P.Nair
>Software Engineer,
>Coas India,174,Road No. 72,
>Prasashan Nagar,Jubilee Hills,
>Hyderabad, India


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com