private static final long serialVersionUID = -6362867182441202099L;
public HttpSession getSessionIfLoggedOrThrowException() throws NotLoggedInException {
HttpSession session = null;
if (session == null)
throw new NotLoggedInException();
@SuppressWarnings("unused")
Object userIdS = session.getAttribute("UserId");
if (userIdS == null)
throw new NotLoggedInException();
Long userid = new Long((String) session.getAttribute("UserId"));
if (userid == null || userid == -1)
throw new NotLoggedInException();
return session;
}