Example usage for javax.servlet.http HttpServletRequest getSession

List of usage examples for javax.servlet.http HttpServletRequest getSession

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getSession.

Prototype

public HttpSession getSession();

Source Link

Document

Returns the current session associated with this request, or if the request does not have a session, creates one.

Usage

From source file:com.naver.timetable.controller.LoginController.java

/**
 * ?  /*from  ww w.  j  a va  2 s .c  o m*/
 * @param loginInfo
 * @param request
 * @return
 */
@RequestMapping(value = "login", method = RequestMethod.POST)
public ModelAndView login(LoginInfo loginInfo, HttpServletRequest request) {
    HttpSession session = request.getSession();
    ModelAndView mv;
    switch (loginBO.login(loginInfo, request)) {
    case LoginBO.LOGIN_SUCCESS:
        String targetPage = session.getAttribute("targetPage") == null ? "/lecture/index"
                : (String) session.getAttribute("targetPage");
        mv = new ModelAndView("redirect:" + targetPage);
        break;

    //? ? ?? 
    case LoginBO.FIRST_LOGIN:
        mv = new ModelAndView("join");
        mv.addObject("majorCategories", categoryBO.getMajorCategories());
        mv.addObject("studentNum", loginInfo.getStudentNum());
        break;

    case LoginBO.LOGIN_FAILED:
    default:
        mv = new ModelAndView("login").addObject("retryMessage", retryMessage);
    }
    return mv;
}

From source file:com.starr.smartbuilds.controller.RegController.java

@RequestMapping(method = { RequestMethod.GET })
public String getReg(Model model, HttpServletRequest req, HttpServletResponse resp) throws IOException {
    HttpSession session = req.getSession();
    User user = (User) session.getAttribute("user");
    if (user == null) {
        model.addAttribute("authMsg", "<a href='./auth'>Log in</a>");
        model.addAttribute("exitReg", "<a href='./reg'>Register</a>");
    } else {/*from  w  w w .  j  ava2  s.co  m*/
        resp.sendRedirect("./");
    }
    model.addAttribute("user", new User());
    return "register";
}

From source file:equipeDFK.sistemaX.controller.ControllerBreadCrumb.java

/**
 * Mtodo que instacia todos usurio no sistema e retorna a pgina 
 * manageUser/*from  w  w w. j  av  a 2s  .  com*/
 * @param req
 * @return
 * @throws SQLException 
 */
@RequestMapping("managerUser")
public String managerUser(HttpServletRequest req) throws SQLException {
    GerenciadorDeUsuario gu = new GerenciadorDeUsuario();
    req.getSession().setAttribute("usuarios", gu.listar());
    return "managerUser";
}

From source file:com.thoughtworks.go.server.web.TokenManager.java

public boolean verify(HttpServletRequest request) {
    String postedToken = request.getParameter(TOKEN);
    String expectedToken = (String) request.getSession().getAttribute(TOKEN);
    return !StringUtils.isBlank(postedToken) && !StringUtils.isBlank(expectedToken)
            && postedToken.equals(expectedToken);
}

From source file:es.tid.fiware.rss.controller.SessionMultiActionController.java

private Object getSessionAttribute(HttpServletRequest req, String name) {
    return req.getSession().getAttribute(name);
}