title: JSP login page session timeout
body: <p>I have created a login page for mock of hotel administrator. Now I want to add session time function to it. In other words, let's say the user leaves the computer (he is still logged into the admin webpage) for like 10 minutes or so. Then when he come back, I want to end the current session and then redirect to login page (this is more secured and his personal info would never be lost!).</p>
  
  <p>How do I make that happen?</p>
  
  <pre><code>public class LoginServlet extends SpringInjectedServlet {
  @Autowired
  private LoginService loginService;
  
  
  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
          throws ServletException, IOException {
  
      String id = req.getParameter("id");
      String password = req.getParameter("password");
  
      String error = null;
  
      //code for checking correct input
  }
  
  // mock
  private boolean check(String id, String password) {
      return loginService.authenticate(id, password);
  }
  
  @Override
  public void init() throws ServletException {
      System.out.println("LoginServlet");
  }
  }
  </code></pre>