Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2009
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Back button in Browser of Home page...plz help

    Can any body provide me codes for restricting back button of window in homepage

    I am Novice in developing webpages.I managed a session of 30 mins,Once I logged into the system through login page it redirects to homepage.jsp.and when I use this Back button in window it goes to previous page (login page).without session expired.
    What i want is to restrict this back button in window of homepage to redirect back to login page.

    Similar thing happens ..Once i logged out And if i press Back button in Window i get intto Homepage.jsp...(This should not happen)

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,509
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    I don't know .jsp ...

    But what if at the very beginning of every page, you check for
    a valid session and decide what to do ... either display the page or not.

    If they are logged-in, only 1 page on your website will be visible.
    You also have your pages set-up for no-caching (using meta tag).

  • #3
    New Coder
    Join Date
    Feb 2009
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Similar thing happens .."Once i logged out And if i press Back button in Window i get intto Homepage.jsp.."..Part i solved..

    But what to do if i click back button in browser in Homepage.jsp...i am still redirecting to home page..
    Login Page>> Home page >>(Back button)>>Login Page

    or

    Login Page>> Home page >>(Back button)>>Login Page >>(Back button) >>Home page

    i want something ..like
    Login Page>> Home page >>(Back button)>> Home page

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,509
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    oh I see now ...

    You can't affect a person's browser history (back or forward buttons).
    So basically, you can control any links you have on your page, but nothing
    you can do with the user's browser.

    The same thing goes for their browser history ...
    They may come back to their computer 2 days from now, and use their browser
    history to get into the middle of your site ... and their back and forward buttons
    will work the same way as before.

    Maybe with some tricky redirects, you can force other pages to load if the
    SESSIONS are a certain status. I'm a PHP guy, so I don't know the answer to
    the .jsp method.

  • #5
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,979
    Thanks
    120
    Thanked 76 Times in 76 Posts
    in jsp jou can something like:

    Pseudocode for login page

    Code:
    if sessionvariable(userAlreadyLoggedIn) = true
    
    response.sendRedirect("../jsp/Home.jsp?....)
    if not loged in, which is anyway if sessin expired, or not logged in at all, this would then show login page.


  •  

    Posting Permissions

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