RE: Question about sessions
> -Original Message- > From: A Yang [mailto:[EMAIL PROTECTED]] > Sent: Friday, February 16, 2001 3:05 PM > To: [EMAIL PROTECTED] > Subject: Question about sessions > > > If I instantiate a javabean from a JSP: > > scope="session"> > > > > and hand off control to a servlet where I retrieve the > session using: > > HttpSession session = req.getSession(false); > > Shouldn't session.isNew() return "false" because the > session already exists? > I don't think so, IF the client hasn't yet seen the session. I think it only returns false if the request includes the session ID, which it won't until there has been a round-trip back to the client. George McKinney, Developer tantalus communications inc. 500-1122 Mainland Street Vancouver, BC, Canada V6B 5L1 [EMAIL PROTECTED] Direct 604.726.6753 Main604.609.0700 Fax 604.609.0705 www.tantalus.com "When eBusiness experience counts." - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Re: Question about sessions
A Yang wrote: > If I instantiate a javabean from a JSP: > > scope="session"> > > > > and hand off control to a servlet where I retrieve the > session using: > > HttpSession session = req.getSession(false); > > Shouldn't session.isNew() return "false" because the > session already exists? > It depends on how you do your handoff. If you use (or RequestDIspatcher.forward()) in the context of the same request, the client does not know about it yet. No response containing the session ID (as a cookie or a rewritten hyperlink) has ever been transmitted, and the client has never said "i am part of session XYZ", so by definition the session is still considered "new". If you use a sendRedirect(), or wait for a subsequent request, the servlet container will see that the session is already in existence and isNew will be false. Among other things, this means that the client has positively acknowledged that they are participating in this session (by returning the session ID on the subsequent request). > > Thanks and regards, > Andy > Craig McClanahan > > ___ > Do You Yahoo!? > Get your free @yahoo.ca address at http://mail.yahoo.ca > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Question about sessions
If I instantiate a javabean from a JSP: and hand off control to a servlet where I retrieve the session using: HttpSession session = req.getSession(false); Shouldn't session.isNew() return "false" because the session already exists? Thanks and regards, Andy ___ Do You Yahoo!? Get your free @yahoo.ca address at http://mail.yahoo.ca - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Re: Question about sessions..
Matt Goss wrote: > > John, > the getSession(false) only returns a session if it is not a new one (ie > if request is from another page inside the application). getSession(true) > always returns a session. > Matt Goss > > "John Clark L. Naldoza" wrote: > Thanks Matt, I am using getSession(false), but I still get a session even when it is my first time accessing the browser... i.e. if( getSession(false) == null ) { System.out.println( No Session ); } else { System.out.println( "Has a session" ); } Mine would print out has a session...;-( are there any extra settings in the server.xml or web.xml that I should know about? Thanks in advance.. -- /) John Clark Naldoza y Lopez (\ / )Software Design Engineer II ( \ _( (__ Web-Application Development_) )_ (((\ \> /_>Cable Modem Network Management System <_\
Re: Question about sessions..
John, the getSession(false) only returns a session if it is not a new one (ie if request is from another page inside the application). getSession(true) always returns a session. Matt Goss "John Clark L. Naldoza" wrote: > Hello All, > > Why is it that I am getting a session, even though I have set call > getSesssion(false) and it is the first time that my browser has > accessed it... > > I'm using Tomcat 3.2.1 under Linux 2.2.17 > > I have set the following in the web.xml > > > > 0 > > > > Any help, pointer or ever RTFMs would be appreciated (I hope the URLs > are in order though..;-) > > Thanks in advance. > > Cheers, > > John Clark > -- > /) John Clark Naldoza y Lopez (\ > / )Software Design Engineer II ( \ > _( (__ Web-Application Development_) )_ > (((\ \> /_>Cable Modem Network Management System <_\( \_/ / NEC Telecom Software Phils., Inc. \ \_/ ) > \ / \ / >\_/ phone: (+63 32) 233-9142 loc. 3112\_/ >/ / cellphone: (+63 919) 241-4612 \ \ > / / email: [EMAIL PROTECTED]\ \ > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, email: [EMAIL PROTECTED] begin:vcard n:Goss;Matt tel;fax:919-657-1501 tel;work:919-657-1432 x-mozilla-html:FALSE url:www.rtci.com org:RTCI;Custom Solutions adr:;;201 Shannon Oaks Circle;Cary;NC;27511;US version:2.1 email;internet:[EMAIL PROTECTED] title:Web Developer fn:Matt end:vcard - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Question about sessions..
Hello All, Why is it that I am getting a session, even though I have set call getSesssion(false) and it is the first time that my browser has accessed it... I'm using Tomcat 3.2.1 under Linux 2.2.17 I have set the following in the web.xml 0 Any help, pointer or ever RTFMs would be appreciated (I hope the URLs are in order though..;-) Thanks in advance. Cheers, John Clark -- /) John Clark Naldoza y Lopez (\ / )Software Design Engineer II ( \ _( (__ Web-Application Development_) )_ (((\ \> /_>Cable Modem Network Management System <_\