title: How can I change the back button function in navigation toolbar?
body: <p>I have developed a simple web application using JSP. It has a login page which contains username, password fields and sumbit button. It has a logout page which contains a link to the login page. And there are some pages like page1, page2, page3, page4, etc.</p>
  
  <p>Normal workflow is the following:</p>
  
  <ul>
  <li>After login comes page1.</li>
  <li>Then click some action and it will go to page2.</li>
  <li>Then click some action and it will go to page3.</li>
  <li>Then click some action and it will go to page4. So now I am in page4.</li>
  <li>Now click back button in navigation toolbar in browser, generally go to previous page (page3).</li>
  </ul>
  
  <p>But my requirement is, if you click back button in navigation toolbar from any page in the application, then you should go to logout page. For example: if you are in page4 and press the back button, then you should go to logout page and not to page3.</p>
  
  <p>How to achieve this? Is it anyway possible? Maybe with Javascript?</p>
  
  <hr>
  
  <p>How can I trace and control the browser back button function in navigation tool-bar?</p>
  
  <p>But my original requirement :</p>
  
  <p>I have developed secured application using JSF framework.</p>
  
  <p>And also i use  scope (session scope)</p>
  
  <p>In my application i use this following code ... but not work it...</p>
  
  <pre><code>public class **LogoutPhaseListener** implements **PhaseListener**
  {
  
   public void **afterPhase**(PhaseEvent event)
   {
   }
  
  
   public void **beforePhase**(PhaseEvent event)
   {
  
          FacesContext facesContext = event.getFacesContext();
          HttpServletResponse httpServletResponse = (HttpServletResponse) facesContext.getExternalContext().getResponse();
          httpServletResponse.addHeader("Pragma", "no-cache");
          httpServletResponse.addHeader("Cache-Control", "no-cache");
          httpServletResponse.addHeader("Cache-Control", "must-revalidate");
          httpServletResponse.addHeader("Expires", "Mon, 8 Aug 2006 10:00:00 GMT");
          httpServletResponse.addHeader("Cache-Control", "no-store");
   }
  
  
   public PhaseId **getPhaseId**()
   {
  
          return PhaseId.RENDER_RESPONSE;
   }
  
  }
  </code></pre>
  
  <p>If i click back button in browser, then it go to previous page... </p>
  
  <p>but i want to go logout page..when i click back button in browser...the above code <strong>not</strong> perfectly work it..</p>