A Yang wrote:

> If I instantiate a javabean from a JSP:
>
> <jsp:useBean id="myBean" class="com.mycorp.somebean"
> scope="session">
> <jsp:setProperty name="myBean" property="*"/>
> </jsp:useBean>
>
> 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 <jsp:forward> (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]

Reply via email to