Discussions

Web tier: servlets, JSP, Web frameworks: Retrieving session

  1. Retrieving session (4 messages)

    Hi,

      My app. interacts with a payment gateway. I need to resume my older session once the transaction is over. Have achieved it by storing my session in a HashMap and putting the HashMap in application scope. Iam able to retrieve the same once the transaction is over.

      But the problem is whenever I call
    HtptpSession session = req.getsession();
    it creates a new session for me.

    Also similar problem in the jsps with <jsp:useBean> tag.

    Any suggestions wud be appreciated.

    Thanks.
    Cheenu.

    Threaded Messages (4)

  2. Retrieving session[ Go to top ]

    Hi,&nbsp;&nbsp;My app. interacts with a payment gateway. I need to resume my older session once the transaction is over. Have achieved it by storing my session in a HashMap and putting the HashMap in application scope. Iam able to retrieve the same once the transaction is over.&nbsp;&nbsp;But the problem is whenever I call HtptpSession session = req.getsession();it creates a new session for me.Also similar problem in the jsps with <jsp:useBean> tag.Any suggestions wud be appreciated.Thanks.Cheenu.

    Hi,

    There is a isNew() method in HttpSession that can be used to check if the session is new or old. The API says: Returns true if the client does not yet know about the session or if the client chooses not to join the session.
    Maybe you could use this method. AFAIK request.getSession() always returns a new session.

    Hope this helps.
  3. Retrieving session[ Go to top ]

    Try using req.getSession(false);

    This should return a pre-existing session.

    Hope it helps,

    Sreeni
  4. Restoring Session[ Go to top ]

    Try using req.getSession(false);

    This doesn't work. I t just creates a new session.
  5. Restoring Session[ Go to top ]

    Request.getSession(boolean create) must create an existing session, if one exists and if it doesn't must return null..

    Sreeni