How to retain session variable


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: How to retain session variable

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Posts
    2

    How to retain session variable

    Hi,

    I am trying to retain the Session variable which is getting removed(deleted) in one of the Actions.
    I tried passing the Session variable to another session variable and at the end, reassigned the changed variable to the original variable.
    Even this does not work. After deleting the original variable, the contents of the new session variable are also getting deleted.

    Can any body help me to resolve this.

  2. #2
    Join Date
    Jun 2006
    Location
    Pune
    Posts
    3

    How to retain the session value

    Try to save the value of the session in a String variable and pass it using URL rewriting. and then retrive the value using getParameter();
    try this...
    first pass the Session value in the servlet context.
    HttpSession sess = req.getSession(true);
    ServletContext context = getServletContext();
    context.setAttribute("sessionId",sess.getId());


    Now in another servlet...
    Object sessionIdObj = context.getAttribute("sessionId");
    String sessionIdValue = sessionIdObj.toString();


    Now simply use the value stored in sessionIdValue, to retain the session.

Similar Threads

  1. Replies: 0
    Last Post: 08-27-2002, 12:21 PM
  2. Session Variable
    By Wyle in forum ASP.NET
    Replies: 2
    Last Post: 07-06-2001, 01:10 AM
  3. capturing value in a session variable
    By Sachin in forum ASP.NET
    Replies: 0
    Last Post: 11-11-2000, 02:18 AM
  4. Session variable problems
    By Nate in forum Enterprise
    Replies: 2
    Last Post: 10-13-2000, 12:38 PM
  5. Session variable problems
    By Nate in forum ASP.NET
    Replies: 5
    Last Post: 09-01-2000, 03:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center