Results 1 to 4 of 4
  1. #1
    shivakumari is offline Member
    Join Date
    Mar 2009
    Posts
    8
    Rep Power
    0

    Default how to clear the session when leaving a page.

    Hi..
    I created a login page which contains username and password fields for users to login. After login,when click the back button the username and password values are displayed in the username and password fields.

    Is there any way to clear username and password fields when the user leaving the login page.

  2. #2
    kattavijay's Avatar
    kattavijay is offline Member
    Join Date
    Jan 2009
    Location
    Hyderabad,india
    Posts
    21
    Rep Power
    0

    Default

    use this method to invalidate the sessions,

    session.invalidate();

    kattavijay

  3. #3
    shivakumari is offline Member
    Join Date
    Mar 2009
    Posts
    8
    Rep Power
    0

    Default Thanks for your response

    Hi..
    Thanks for your response.
    I need one more thing.
    Can u give any sample code for avoiding previous page when we click on the back button of InternetExplorer(any browser).
    Can u tell me Where do we place session.invalidate().

  4. #4
    kattavijay's Avatar
    kattavijay is offline Member
    Join Date
    Jan 2009
    Location
    Hyderabad,india
    Posts
    21
    Rep Power
    0

    Default

    try this piece of code :

    // Get the existing session.
    HttpSession session = request.getSession(false);

    // Invalidate the existing session.

    // Note :
    // We may need to invalidate the existing session to ensure that all previous session data(s) for the user is removed from the context.

    // Example : When user login to the application after Session Times out,we may not
    need his previous session data and we need to create a new session for the user.

    if(session!=null) {
    session.invalidate();
    }
    // Create a new session for the user.
    session = request.getSession(true);

Similar Threads

  1. Go back to previous page using session in JSP page
    By gopikarikati009 in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 06-23-2011, 11:30 AM
  2. Replies: 1
    Last Post: 04-22-2009, 12:20 AM
  3. Replies: 2
    Last Post: 12-23-2008, 07:35 PM
  4. How to clear JDesktopPane
    By hendrix79 in forum New To Java
    Replies: 12
    Last Post: 12-11-2008, 12:25 AM
  5. Help, someone clear up Interfaces for me
    By mathias in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 03:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •