2 Replies Latest reply on Oct 10, 2005 10:07 AM by Alexander Fedorenko

    Session Values Getting Destroyed

    BG Kiran Newbie

      We are generating an Unique Number and storing the same in a variable called temp and adding it to the Session. We are now passing this variable temp in a URL to another server say Server-2 for transactions.
      Now from Server-2 the same value will be sent in the URL to Server1.

      The value from Server-2 will be compared to the value in the Server-1 which is in Session.

      When the value is tried to retrive from the session ,the session is getting Destroyed.

      This is what the code I have written


      if(session.getAttribute("USER1")!=null)
      {
      String userFromSession = session.getAttribute("USER1").toString();


      String user1 = request.getParameter("user1");


      Can you please suggest a solution for this.


      Regards
      Kiran

        • 1. Re: Session Values Getting Destroyed
          kourosh bagheri Newbie

          Hi Kiran!

          I don't know if you have already the sloution of your problem, but if not, here it is:

          You have to cast the object, which is placed in the session scope to your desired type. The Method toString() is not the right way.

          It should look like this:

          String userFromSession = (String) session.getAttribute("USER1");

          Bye
          David


          • 2. Re: Session Values Getting Destroyed
            Alexander Fedorenko Newbie

            This could be the browser's behaviour, I faced the issue recently.

            I noticed cookie settings :

            Browser's settings (Firefox) :
            - Keep cookies : until they expired

            Tomcat's settings :
            - Cookie generated by tomcat with name JSESSIONID, has attribute
            "Expires : at the end of session' .


            For browser, when you visit URL2 , you leave URL1 actually , and it means - "End of session for URL1" .

            You can solve the problem in 2 ways :

            1) set browser's setting : Keep cookies : until I close browser

            2) always send to URL2 also session id to get back to URL1 .
            In other words, your URL1 to return must look like

            URL1;jsessionid=XXXXXXXXXXXXXXX

            always .