Results 1 to 6 of 6

Thread: Destroying Session in JSP

  1. #1
    Join Date
    Nov 2009
    Posts
    862

    Destroying Session in JSP

    Hello, I am not able to destroy the session. When you click the back button, it always comes back in session and it must refresh the page to the protection of the session page redirects to the authentication session yet exists.
    I tried everything with session.setAttribute, session.removeAttribute, session.invalidate (), session = null, but you can still click the back button and come back in page session.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Destroying Session in JSP

    Hello, you can simply make use of the code below for getting the solution for your problem.
    Code:
    <% if(session.getAttribute("time")==null)
    {  
    out.println("Start");  
    session.setAttribute("Date",new java.util.Date());            
    } 
    else
    {  
    out.println("Next");  
    }  
    %>

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Destroying Session in JSP

    If you want to invalidate the session then you must need to use the code below:
    Code:
    rew.getSession().invalidate();
    But when you do back in your browser, it does not reload the page from the server, but it is in the cache on the client side. So, you can't stop from viewing it. So, you can use the javascript and solve your problem. For that you can make use of the code below:
    Code:
    window.Rentals.replace(url);
    It replaces the page so you can keep on page one page which is better but still not optimal.

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: Destroying Session in JSP

    If you are making the call as below:
    Code:
    request.getSession().invalidate();
    Then you must not use the false parameter passing as below:
    Code:
    request.getSession(false).invalidate();
    As if you are using above one then it is not provide you what you want. As the default value is true.

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Destroying Session in JSP

    Hello, I have tried this while making my project in jsp. I tried window.location.replace (url). It works but I wonder if there is a way to erase the history of pages visited in my sessions applicable to that user can not return to the session pages. I think history in javascript, get the long history of Array, then retrieve the url history with item. I don't think that there is any way to solve this problem.

  6. #6
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Destroying Session in JSP

    Hello, If you want to perform the task from which you can able to force the browser from which it can remove the cached HTML pages generated by JSP pages. For that you just need to make use of the code below at the beginning of the Jsp page.
    Code:
    <%
    response.setHeader ( "Pragma", "no-cache");
    response.setDateHeader ( "Expires", 0);
    response.setHeader ( "Cache Remove", "no-cache");
    response.setHeader ( "Cache Remove", "no-store");
    %>

Similar Threads

  1. Are tablets and smartphones destroying the handheld market.
    By Dorkfoot in forum Portable Devices
    Replies: 6
    Last Post: 09-09-2011, 09:27 PM
  2. Replies: 4
    Last Post: 17-01-2011, 11:14 AM
  3. Replies: 4
    Last Post: 24-12-2010, 07:58 AM
  4. DX58SO Destroying RAM
    By Patricia-USA in forum Motherboard Processor & RAM
    Replies: 5
    Last Post: 30-06-2010, 03:12 AM
  5. Replies: 3
    Last Post: 31-07-2009, 01:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,145,365.72089 seconds with 16 queries