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.tce.oauth2.spring.client.controller.TodoController.java

@RequestMapping(value = "/todos/add", method = RequestMethod.POST)
public String add(@ModelAttribute("todo") Todo todo, HttpServletRequest request) {
    todo.setUsername((String) request.getSession().getAttribute("username"));
    todoService.add((String) request.getSession().getAttribute("access_token"), todo);
    return "redirect:/todos";
}

From source file:org.openmrs.module.radiology.web.controller.main.MainController.java

@RequestMapping(method = RequestMethod.GET)
public String firstView(HttpServletRequest request, Model model) {

    HttpSession session = request.getSession();
    Map<Concept, Set<Concept>> testTreeMap = generateTestTreeMap();
    System.out.println("testTreeMap ===> " + testTreeMap);
    session.setAttribute(RadiologyConstants.SESSION_TEST_TREE_MAP, testTreeMap);

    return "/module/radiology/main/main";
}

From source file:com.alibaba.cobar.manager.web.PermissionInterceptor.java

private boolean permissioned(HttpServletRequest request) {
    UserDO user = (UserDO) request.getSession().getAttribute("user");
    if (user == null)
        return true;

    String userType = null;/* ww  w .  j a v a 2s.co m*/
    if (user.getUser_role().equals(ConstantDefine.SYSTEM_ADMIN)) {
        userType = ConstantDefine.SYSTEM_ADMIN;
    } else {
        userType = ConstantDefine.CLUSTER_ADMIN;
    }

    HashSet<String> set = (HashSet<String>) nonMatchURIMap.get(userType);
    String url = request.getServletPath().trim();

    return set.contains(url);
}

From source file:com.tce.oauth2.spring.client.controller.TodoController.java

@RequestMapping(value = "/todos/{id}/delete", method = RequestMethod.POST)
public String delete(@PathVariable("id") Long id, HttpServletRequest request) {
    todoService.delete((String) request.getSession().getAttribute("access_token"), id);
    return "redirect:/todos";
}

From source file:de.thm.arsnova.LoginAuthenticationSucessHandler.java

@Override
protected String determineTargetUrl(final HttpServletRequest request, final HttpServletResponse response) {
    HttpSession session = request.getSession();
    if (session == null || session.getAttribute("ars-login-success-url") == null) {
        return targetUrl;
    }//from   ww w.  j  a va  2 s.  c  o m
    String redirect = (String) session.getAttribute("ars-login-success-url");

    return redirect;
}

From source file:org.openmrs.module.laboratory.web.controller.main.MainController.java

@RequestMapping(method = RequestMethod.GET)
public String firstView(HttpServletRequest request, Model model) {

    HttpSession session = request.getSession();
    Map<Concept, Set<Concept>> testTreeMap = generateTestTreeMap();
    logger.info("Test tree: " + testTreeMap);
    session.setAttribute(LaboratoryConstants.SESSION_TEST_TREE_MAP, testTreeMap);
    return "/module/laboratory/main/main";
}

From source file:com.etcc.csc.presentation.action.GetTollTagRetrieveVehicleAction.java

private TagDTO retrieveVehicle(String vehicleIndex, HttpServletRequest request) {
    return (TagDTO) ((Map) request.getSession().getAttribute("savedVehicles")).get(vehicleIndex);
}

From source file:com.liferay.portal.events.LogSessionIdAction.java

public void run(HttpServletRequest req, HttpServletResponse res) throws ActionException {

    HttpSession ses = req.getSession();

    _log.debug("Session id " + ses.getId() + " is " + (!ses.isNew() ? "not " : "") + "new");
}

From source file:com.sunney.eweb.controller.LoginController.java

@RequestMapping(value = "/checkLogin", method = RequestMethod.POST)
@ResponseBody/*from  w  ww  .  ja  v  a2s.c om*/
public Object checkLogin(HttpServletRequest request) {
    HttpSession session = request.getSession();
    String userId = request.getParameter("userId");
    String password = request.getParameter("password");
    Result result = new Result();
    if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(password)) {

    }
    logger.info("======================" + userId + password);
    UsersDTO user = usersService.queryUsersByUserId(userId);
    if (user != null) {
        if (user.getPassword().equals(password)) {
            logger.info("login success");
            result.setSuccess(true);
            result.setInfoCode("success");
            session.setAttribute(GlobalConstant.ADMIN_COOKIE_NAME, user);
        } else {
            result.setSuccess(false);
            result.setInfoCode("??");
            logger.info("??");
        }
    } else {
        result.setSuccess(false);
        result.setInfoCode("?");
        logger.info("?");
    }
    return result;
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.authenticate.LoginExternalAuthReturn.java

private void removeLoginProcessArtifacts(HttpServletRequest req) {
    req.getSession().removeAttribute(ATTRIBUTE_REFERRER);
    LoginProcessBean.removeBean(req);
}