Example usage for javax.servlet.http HttpSession setAttribute

List of usage examples for javax.servlet.http HttpSession setAttribute

Introduction

In this page you can find the example usage for javax.servlet.http HttpSession setAttribute.

Prototype

public void setAttribute(String name, Object value);

Source Link

Document

Binds an object to this session, using the name specified.

Usage

From source file:com.naver.timetable.bo.LoginBO.java

public int login(LoginInfo loginInfo, HttpServletRequest request) {
    //?   ?//from www .  j  a va 2 s .co  m
    //http client  http://eclass2.hufs.ac.kr:8181/ilos/lo/login_branch.acl  

    List<NameValuePair> loginParam = Lists.newArrayList();
    loginParam.add(new BasicNameValuePair("usr_id", loginInfo.getStudentNum()));
    loginParam.add(new BasicNameValuePair("usr_pwd", loginInfo.getPasswd()));

    // ? 
    if (httpClientBO.getHttpBody(loginUrl, "POST", loginParam).length() < 1000) {
        User user = userDAO.login(loginInfo.getStudentNum());
        if (user != null) {
            HttpSession session = request.getSession();
            session.setAttribute("user", user);
            return LOGIN_SUCCESS;
        } else {
            return FIRST_LOGIN;
        }
    } else {
        return LOGIN_FAILED;
    }
}

From source file:com.acc.storefront.filters.StorefrontFilter.java

protected void markSessionInitialized(final HttpSession session) {
    session.setAttribute(this.getClass().getName(), "initialized");
}

From source file:org.openmrs.module.clinicalsummary.web.controller.summary.SummaryFormController.java

@RequestMapping(method = RequestMethod.POST)
public void processPage(final @ModelAttribute("summary") Summary summary, final HttpSession session) {
    Context.getService(SummaryService.class).saveSummary(summary);
    session.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "clinicalsummary.summary.saved");
}

From source file:ua.aits.oblenergo_site.controller.AjaxAndFormController.java

@RequestMapping(value = { "/system/login.do", "/system/login.do/" }, method = RequestMethod.POST)
public ModelAndView login(@RequestParam("user_id") String user_id, @RequestParam("user_name") String user_name,
        @RequestParam("user_password") String user_password, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    UserModel user = Users.getOneUserFullById(user_id);
    HttpSession session = request.getSession(true);
    session.setAttribute("user", user);
    if (user.user_role == 1) {
        return new ModelAndView("redirect:" + "/system/index");
    } else {//  w w w.ja  v a2 s. co  m
        return new ModelAndView("redirect:" + "/system/index");
    }
}

From source file:cn.vlabs.umt.ui.servlet.login.AppLogin.java

@Override
protected void redirectToLogin(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String loginURL = request.getParameter("LoginURL");
    String vmtApp = request.getParameter("LoginAPP");
    if (loginURL == null || vmtApp == null) {
        return;/*from  w  w w . ja v a2  s  . com*/
    }
    HttpSession session = request.getSession();
    session.setAttribute("applogin.LoginURL", loginURL);
    session.setAttribute("applogin.LoginAPP", vmtApp);

    forwardToLogin(request, response, loginURL, vmtApp, false);
}

From source file:com.gian.controller.SecurityController.java

@RequestMapping(value = "login", method = RequestMethod.POST)
public ModelAndView login(HttpServletRequest request, @RequestParam String login,
        @RequestParam String password) {

    ModelAndView mv = null;/*from  w ww . ja v a2s .  c  om*/
    boolean b = userService.loginUser(login, password);

    if (b == true) {

        //Create a session variable for login

        HttpSession stateSession = request.getSession(true);
        stateSession.setAttribute("id", "logged");

        _log.info("Start Login Session!");
        mv = new ModelAndView("home");
        mv.addObject("user", login);

    } else {

        HttpSession stateSession = request.getSession();
        stateSession.removeAttribute("id");

        _log.info("Login Failed!");
        mv = new ModelAndView("index");
        mv.addObject("messageFromController", "Login Failed!");
    }

    return mv;

}

From source file:de.ingrid.interfaces.csw.admin.WelcomeController.java

@RequestMapping(value = "/welcome.html", method = RequestMethod.GET)
public String welcome(final HttpSession session) throws Exception {
    if (session.getAttribute("postCommandObject") == null) {
        session.setAttribute("postCommandObject", new Command());
    }/*from   w  w w . j a  va 2 s. c o  m*/
    return "redirect:" + ManageHarvesterController.TEMPLATE_LIST_HARVESTER;
}

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

void create(HttpSession session) {
    synchronized (session) {
        if (null == session.getAttribute(TOKEN)) {
            session.setAttribute(TOKEN, UUID.randomUUID().toString());
        }/* w ww.  jav  a  2  s . c  o  m*/
    }
}

From source file:com.education.lessons.ui.server.login.AbstractLoginController.java

/**
 * Handles login (internally)./* w  w  w . ja  va2s .co  m*/
 */
protected void signIn(HttpSession session, User user) {
    session.setAttribute(WebContext.CONTEXT_USER_ATTR, user);
}

From source file:net.gplatform.sudoor.server.social.model.SimpleSignInAdapter.java

@Override
public String signIn(String localUserId, Connection<?> connection, NativeWebRequest request) {
    SSAuth.signin(localUserId, null);//from  ww  w .  ja  v a 2 s  . c o m

    HttpServletRequest nativeReq = request.getNativeRequest(HttpServletRequest.class);
    HttpSession session = nativeReq.getSession();
    session.setAttribute(CONNECTION_KEY, connection);

    String providerId = connection.getKey().getProviderId();
    String parameter = "?entryPoint=oauth_" + providerId;

    String targetUrl = "/";
    String originalUrl = extractOriginalUrl(request);
    if (StringUtils.isNotEmpty(originalUrl)) {
        targetUrl = StringUtils.trimToEmpty(originalUrl);
    }
    return targetUrl + parameter;
}