On Wed, 5 Jan 2005 17:16:46 -0800 (PST), ans <[EMAIL PROTECTED]> wrote:
> Hi,
> I am in the process of converting a webapp written
> using servlets in to struts actions.
> 
> When I open the browswer and when I enter into an
> action class for the first time, then my
> 'request.isRequestedSessionIdValid' is returning false
> Before calling the
> request.isRequestedSessionIdValid(),
> I perform request.getSession();
> 
> Subsequent times, it is returning true
> 
> What is going on here with
> request.isRequestedSessionIdValid()?
> 

If you read the precise semantics of isRequestedSessionValid(), you
will see that this behavior is exactly as it should be.

Consider the following timeline:

(A) Request 1 comes in:
- With no session id (because the session did not exist yet
- Calling request.getSession() creates a new session,
  but one that the client doesn't know about yet
- request.isRequestedSessionValid() returns false
- You render the page, including the session id

(B) Request 2 comes in
- With a session id
- Therefore request.isRequestedSessionValid() will return true

Craig


> Thanks
> -Aswath
> 
> Following is some simple code I am using for testing
> purpose
>         public ActionForward execute(ActionMapping mapping,
> ActionForm form,
>                         HttpServletRequest request, HttpServletResponse
> response)
>                         throws Exception {
> 
>                 String redirectPage = "GLOBAL_VIEWMANAGER_PAGE";
>                 // After successful User Login
>                 HttpSession session = request.getSession();
>                 session.setAttribute("test", "test");
>                 System.out.println ("isNew = " + session.isNew());
>                 System.out.println ("isRequestedSessionIdValid() = "
> + request.isRequestedSessionIdValid());
>                 return mapping.findForward(redirectPage);
>         }
> }
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - 250MB free storage. Do more. Manage less.
> http://info.mail.yahoo.com/mail_250
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to