title: Redirect back to a page after a login
body: <p>I'm doing a simple forum with a series of <code>Servlets</code> that each represent a home, topic, postedit, login and userlist page. On some of these pages there is a link that appears when a user isn't logged in.</p>
  
  <p>What I'd like to achieve is to trigger a redirection (using forward() on a RequestDispatcher) after a login so the browser goes back to the page where a user was before clicking the login link. In order to do this, I see two solutions.</p>
  
  <p>The first solution is to have an HTML <code>Form</code> with a login button and an invisible field that will contain information that will say what page to redirect as a <code>Parameter</code>.  This is doable but I'd like to try something else.</p>
  
  <p>The second solution is to add an <code>Attribute</code> to the <code>session</code> that represents the first "page" in some way. This could contain a String but this is no different from the first approach. Another twist would be to add a reference to the HttpServlet and to use instanceof or a static String variable that could be used to identify the Servlet in some way. However, this would require creating a common ancestor class for all the <code>Servlets</code>.</p>
  
  <p>Perhaps there is another simple solution that you can see that would form a good compromise ? Or, maybe one of the above solutions is perfectly acceptable ?</p>