title: disable go back function in browser using servlet
body: <p>I made a simple website with login page, everything works fine except when user click on GO BACK button in browser, the previous page shows up after logout.</p>
  
  <p>I have tried to track session, but not successful, any suggestions? 
  ps: i prefer to achieve this on server side programming.</p>
  
  <p>Thanks</p>
  
  <p>Here is my redirect url filter, if anything, this could be where the problem is</p>
  
  <pre><code>public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) 
                      throws IOException, ServletException 
  {
      HttpServletRequest request = (HttpServletRequest) req;
      HttpServletResponse response = (HttpServletResponse) res;
  
      HttpSession session= request.getSession(false);
  
     if(request.getRequestURI().compareToIgnoreCase("/login.jsp")!=0&amp;&amp;
             request.getRequestURI().compareToIgnoreCase("/")!=0)
     {
              if (session!=null &amp;&amp;!session.isNew()) 
              {
                      chain.doFilter(req, res);
              }
              else 
              {
                  response.sendRedirect(request.getContextPath()+"/login.jsp"); 
                 }
    }
     else
     {
         chain.doFilter(req, res);
  
     }
  }
  </code></pre>