Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6143753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:33:39+00:00 2026-05-23T18:33:39+00:00

I want to prohibit the user from going back to a secure page after

  • 0

I want to prohibit the user from going back to a secure page after logout when he/she clicks on the back button on the browser(in my case it is Mozilla Firefox 5.0).
Found two ways,
setting proper headers:

response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.setHeader("Pragma", "No-cache");
response.setDateHeader("Expires", 0);

or disabling the back button using javascript:

<script type="text/javascript">
window.history.forward(1);
</script>

actually the javascript doesn’t disable the back button,just forwards the user one page ahead in the history,should serve the purpose.

But neither works. My logout page is contains the following code:

<script type="text/javascript">
window.history.forward(1);
</script>

<% HttpSession ses=request.getSession(false);
ses.invalidate();
String referer = request.getHeader("Referer");
response.sendRedirect(referer);
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.setHeader("Pragma", "No-cache");
response.setDateHeader("Expires", 0);
%>

Doesn’t serve my purpose.Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:33:40+00:00Added an answer on May 23, 2026 at 6:33 pm

    Those headers needs to be set on all the secured pages themselves, not on the JSP where you’re placing the logout logic which actually belongs in a servlet. Even more, since you’re sending a redirect here, those headers have totally no effect.

    The proper approach would be to map a Filter on the desired URL pattern which does the job. I’m sure that the majority of the answers which you initially found here are also suggesting that 🙂

    See also:

    • Prevent user from seeing previously visited secured page after logout
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project with autotools: automake, autoconf. I want to prohibit make from
Want to update page after jeditable (using gem on_the_spot) has been updated. Below works
Want to show icon for settings UIBarButtonItem on UIToolbar than text button UIBarButtonItem *settingsButton
want to have a Hyperlink-Button in a gridView in which I can display a
want to share a link from my application in windows phone 7. Any one
Want i want to do is i get a number from a php script.
Want to detect the '\n' without going through each and every character of a
Want to know which CSS styles are currently being used on a web page.
Want to change case to lower in whole block in visual mode. If i
I want to exclude properties from bean to json using json-lib at runtime. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.