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:io.muic.ooc.webapp.service.SecurityService.java

public void logout(HttpServletRequest request) {
    request.getSession().invalidate();
}

From source file:com.starit.diamond.server.controller.SecurityController.java

@RequestMapping(value = "/logout", method = RequestMethod.GET)
public String logout(HttpServletRequest request) {
    request.getSession().invalidate();
    return "redirect:/";
}

From source file:cn.leancloud.diamond.server.controller.LoginController.java

@RequestMapping(params = "method=logout", method = RequestMethod.GET)
public String logout(HttpServletRequest request) {
    request.getSession().invalidate();
    return "login";
}

From source file:com.orchestra.portale.controller.CheckController.java

@RequestMapping("/check")
public ModelAndView check(HttpServletRequest request) {
    HttpSession session = request.getSession();
    ServletContext sc = session.getServletContext();
    File f = new File(sc.getRealPath("/"));
    ModelAndView model = new ModelAndView("check");
    model.addObject("mess",
            f.getParentFile().getParentFile().getParentFile().getPath() + File.separator + "BackupImg");
    return model;
}

From source file:com.osbitools.ws.shared.prj.web.GenericPrjMgrWsSrvServlet.java

Git getGit(HttpServletRequest req) {
    return (Git) req.getSession().getServletContext().getAttribute("git");
}

From source file:ui.controller.ControllerParent.java

public User getAuthenticatedUser(HttpServletRequest request) {
    return (User) request.getSession().getAttribute("User");
}

From source file:com.adito.core.actions.AbstractMultiFormDispatchAction.java

private static SubActionWrapper getSubActionWrapper(ActionMapping mapping, ActionForm form,
        ActionMapping subMapping, HttpServletRequest request, int index) throws ClassNotFoundException,
        IllegalAccessException, InstantiationException, InvocationTargetException {
    String formName = subMapping.getName();
    ActionForm subForm = getActionForm(subMapping, request);

    FormBeanConfig formBean = mapping.getModuleConfig().findFormBeanConfig(formName);
    String className = formBean == null ? null : formBean.getType();
    if (className == null)
        return null;

    if (subForm == null || !className.equals(subForm.getClass().getName()))
        subForm = (ActionForm) Class.forName(className).newInstance();

    if ("request".equals(mapping.getScope()))
        request.setAttribute(formName, subForm);
    else/*  w  w  w  . j ava 2 s  .  c o  m*/
        request.getSession().setAttribute(formName, subForm);

    subForm.reset(mapping, request);

    /*
     * We dont want to try and populate all forms on a post, only the one
     * that has requested it. For this the form must have a hidden parameter
     * with the name of 'subForm' and the value being the form name to
     * populate
     */
    AbstractMultiFormDispatchForm dispatchForm = (AbstractMultiFormDispatchForm) form;
    if (formName.equals(dispatchForm.getSubForm())) {
        dispatchForm.setSelectedTab(dispatchForm.getTabName(index));
        BeanUtils.populate(subForm, request.getParameterMap());
    }

    return new SubActionWrapper(subForm, subMapping);
}

From source file:gov.nih.nci.ncicb.cadsr.common.util.SessionUtils.java

public static void setPreviousSessionValues(HttpServletRequest request) {
    String previousSessionId = request.getParameter(CaDSRConstants.PREVIOUS_SESSION_ID);
    log.error("SessionUtil.setPreviousSessionValues at :" + TimeUtils.getEasternTime());

    synchronized (sessionObjectCache) {
        log.error("SessionUtil.setPreviousSessionValues(synchronized Start) at :" + TimeUtils.getEasternTime());
        if (previousSessionId != null) {
            Map map = (Map) SessionUtils.sessionObjectCache.get(previousSessionId);
            Set keys = (Set) map.get(CaDSRConstants.GLOBAL_SESSION_KEYS);
            Map objectMap = (Map) map.get(CaDSRConstants.GLOBAL_SESSION_MAP);
            if (keys != null && objectMap != null) {
                Iterator keyIt = keys.iterator();
                while (keyIt.hasNext()) {
                    String key = (String) keyIt.next();
                    Object obj = objectMap.get(key);
                    request.getSession().setAttribute(key, obj);
                }/*from  w ww. j  a va  2  s .co  m*/
            }
            log.error(
                    "SessionUtil.setPreviousSessionValues(synchronized End) at :" + TimeUtils.getEasternTime());
        }
    }
    log.error("SessionUtil.setPreviousSessionValues end at :" + TimeUtils.getEasternTime());
}

From source file:com.spring.tutorial.formHandlers.LoginController.java

@RequestMapping(value = "/logout", method = RequestMethod.GET)
public String logout(HttpServletRequest request) {
    request.getSession().setAttribute("username", null);
    return "redirect:/login";
}

From source file:com.netsteadfast.greenstep.util.SystemFormUtils.java

public static Map<String, String> processExpression(SysFormMethodVO formMethod, Object actionObj,
        Map<String, Object> actionDatas, PageOf pageOf, SearchValue searchValue,
        List<Map<String, String>> items, Map<String, String> fields, List<String> fieldsId,
        Map<String, String> fieldsMessage, HttpServletRequest request)
        throws ControllerException, ServiceException, Exception {

    Map<String, String> resultMap = new HashMap<String, String>();
    SysFormVO form = findForm(formMethod.getFormId());
    String expression = new String(formMethod.getExpression(), Constants.BASE_ENCODING);
    Map<String, Object> paramMap = getParameters(formMethod, actionObj, actionDatas, pageOf, searchValue, items,
            fields, fieldsId, fieldsMessage);
    ScriptExpressionUtils.execute(formMethod.getType(), expression, null, paramMap);
    if (FormResultType.DEFAULT.equals(formMethod.getResultType())) {
        SysFormTemplateVO template = findTemplate(form.getTemplateId());
        setViewPage(resultMap, FORM_PAGE_PATH + template.getFileName());
        String pageFileFullPath = request.getSession().getServletContext().getRealPath("/");
        pageFileFullPath += FORM_PAGE_PATH + template.getFileName();
        File file = new File(pageFileFullPath);
        if (!file.exists() || getEnableTemplateFileReWriteAlways()) {
            if (!file.exists()) {
                logger.warn("no template file: " + pageFileFullPath);
            }// w w  w.j a  v a  2  s . c  om
            file = null;
            writePage(template, request);
        }
        file = null;
    }
    if (FormResultType.JSON.equals(formMethod.getResultType())) {
        setJsonValue(resultMap, (String) ((Map<String, Object>) paramMap.get("datas")).get("jsonMessage"),
                (String) ((Map<String, Object>) paramMap.get("datas")).get("jsonSuccess"));
    }
    if (FormResultType.REDIRECT.equals(formMethod.getResultType())) {
        setRedirectUrl(resultMap, (String) ((Map<String, Object>) paramMap.get("datas")).get("redirectUrl"));
    }
    return resultMap;
}