code: public String getUserId(HttpServletRequest request) {
  		HttpSession session = request.getSession();
  		return (String) session.getAttribute("userId");
  	}
docs: Get the current user's ID from the session
  
  @return string user id or null if no one is logged in