title: After logout when I click back button in browser still the page accessible while refreshing it works fine
body: <p>I am having a web page in <code>jsp</code> and <code>servlet</code></p>
  
  <p>I am login the page and it is redirected into the <code>homepage.jsp</code></p>
  
  <p>In login I am setting session variables as follows in my servlet <code>login.java</code> as follows:</p>
  
  <pre><code>HttpSession ss = rq.getSession(true);
  ss.setAttribute("uid", rstusrdetail.getInt(1));
  ss.setAttribute("username", rstusrdetail.getString(2));
  </code></pre>
  
  <p>I have a logout button as well and my logout.java as follows:</p>
  
  <pre><code>try {
              HttpSession ss = rq.getSession(false);
              if (ss.getAttribute("uid") == null || ss.getAttribute("username") == null ) {
                  rs.sendRedirect("/");
              }
  
              rs.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
              rs.addHeader("Cache-Control", "post-check=0, pre-check=0");
              rs.setHeader("Pragma", "no-cache");
              rs.setDateHeader("Expires", 0);
              HttpSession session = rq.getSession(false);
              session.setAttribute("uid", null);
              session.setAttribute("username", null);            
              session.invalidate();
              rs.sendRedirect("/");
          } catch (Exception exp) {
              RequestDispatcher dd = rq.getRequestDispatcher("/");
              dd.forward(rq, rs);
          }
  </code></pre>
  
  <p><strong>After logout when I click the back button it is redirected to the homepage.jsp</strong></p>
  
  <p>If I refresh then I am getting session expire message . If I directly access the page also I am getting session expire message. </p>
  
  <p>How can I get on clicking back button to get session expire with out refreshing or is there any ways to disable back button in browser?</p>