code: public void doLogin(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
          if (!common.checkPost(request, response)) return;
  
          String username = request.getParameter("username");
          if (username == null) {
              response.sendError(400, "Missing field \"username\".");
              return;
          }
  
          String usernameError = checkUsername(username);
          if (usernameError != null) {
              response.sendError(400, "Invalid username: " + usernameError);
              return;
          }
  
          // Lookup user.  If the user doesn't exist, create it.
          User user;
          synchronized (common.userDb) {
              user = common.userDb.get(username);
              if (user == null) {
                  user = new User();
                  user.username = username;
                  user.dropboxAccessToken = null;
  
                  common.userDb.put(user.username, user);
                  common.saveUserDb();
              }
          }
  
          request.getSession().setAttribute("logged-in-username", user.username);
          response.sendRedirect("/");
      }
docs: Login form handler.