title: Best strategy to handle page navigation in JSP
body: <p>I am exploring JSP to implement dynamic web pages. One issue to solve is navigation between pages. Users have the possibility to go back and forward in their browsers.</p>
  
  <p>This has to be handled. If someone logs out (for example), we don't want someone else to retrieve the session or data by clicking 'go back'. Another example is that we don't want to resubmit forms twice.</p>
  
  <p>I am looking for tips and advices to solve page navigation issues. I would like to create a list of issues one has to take care of + possible solutions:</p>
  
  <p><strong>Issues:</strong></p>
  
  <ul>
  <li>Making sure sessions cannot be retrieved/hijacked with go back/forward clicks</li>
  <li>Making sure forms and not submitted twice</li>
  <li>Making sure users cannot fiddle cookies or URL data or hidden fields to break control flow and security</li>
  </ul>
  
  <p><strong>Solutions:</strong></p>
  
  <ul>
  <li>Implement a stack of visited pages</li>
  <li>When a page is invoked, register the moment it is displayed to differentiate new requests from 'go back'</li>
  <li>Control current session</li>
  </ul>
  
  <p>P.S.: I have seen this <a href="https://stackoverflow.com/questions/2763978/pure-jsp-page-navigation-best-practice">question</a>, but there is no real answer to it.</p>