code: private String loginDestinationUrl(final HttpServletRequest request) {
          final HttpSession session = request.getSession();
          final String requestReferer = request.getHeader("referer");
          final String sessionReferer = (String) session
                  .getAttribute(SESSION_REFERER_KEY);
          if (useReferer(requestReferer)) {
              return requestReferer;
          } else if (useReferer(sessionReferer)) {
              return sessionReferer;
          } else {
              return servletPath + "/person?db=schoeller&id=I1";
          }
      }
docs: Try to figure out where to go after login. We have to do a
  few tricks in order to carry that around.
  
  @param request the request object
  @return the URL