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:egovframework.com.ext.jfile.session.SessionUploadChecker.java

public static void unCheck(HttpServletRequest request, String fileId) {

    log.debug(new StringBuilder().append("\n").append("\n")
            .append("================= session upload uncheck =================").append("\n")
            .append(" jsessionid_fileId : ").append(request.getSession().getId()).append("\n")
            .append("==========================================================").append("\n").toString());

    if (sessionMap.containsKey(request.getSession().getId() + "_" + fileId)) {
        sessionMap.remove(request.getSession().getId() + "_" + fileId);
    }//from   w  w w.  j av a2 s.  co m
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.java

/**
 * Store this login process bean in the session.
 *//*from   w w w.j  a va  2  s  .  c om*/
public static void setBean(HttpServletRequest request, LoginProcessBean bean) {
    HttpSession session = request.getSession();
    session.setAttribute(SESSION_ATTRIBUTE, bean);
}

From source file:com.salesmanager.core.util.LocaleUtil.java

public static Locale getLocale(HttpServletRequest req) {
    Locale locale = (Locale) req.getSession().getAttribute("WW_TRANS_I18N_LOCALE");

    if (locale == null) {
        locale = LocaleUtil.getDefaultLocale();
    }/*ww w .  ja  v  a  2 s .  c  o m*/
    return locale;
}

From source file:eu.eidas.node.logging.LoggingUtil.java

public static void logServletCall(HttpServletRequest request, final String className, final Logger logger) {
    if (!StringUtils.isEmpty(request.getRemoteHost())) {
        MDC.put(LoggingMarkerMDC.MDC_REMOTE_HOST, request.getRemoteHost());
    }//from   w  w  w . j  av  a  2s .c  o  m
    MDC.put(LoggingMarkerMDC.MDC_SESSIONID, request.getSession().getId());
    logger.info(LoggingMarkerMDC.WEB_EVENT,
            "**** CALL to servlet " + className + " FROM " + request.getRemoteAddr() + " HTTP "
                    + request.getMethod() + " SESSIONID " + request.getSession().getId() + "****");

}

From source file:eionet.gdem.web.struts.stylesheet.StylesheetListLoader.java

public static void loadPermissions(HttpServletRequest httpServletRequest) {
    String user_name = (String) httpServletRequest.getSession().getAttribute("user");
    try {//w w w. ja  v  a 2s  . c  o m
        httpServletRequest.getSession().setAttribute(STYLESHEET_PERMISSIONS_ATTR,
                loadStylesheetPermissions(user_name));
    } catch (Exception e) {
        e.printStackTrace();
        LOGGER.error("Error getting QA script permissions", e);
    }
}

From source file:io.lavagna.web.helper.UserSession.java

public static void setUser(int userId, boolean isUserAnonymous, HttpServletRequest req,
        HttpServletResponse resp, UserRepository userRepository, boolean addRememberMeCookie) {

    req.getSession().invalidate();
    if (addRememberMeCookie) {
        addRememberMeCookie(userId, req, resp, userRepository);
    }/*w w w.ja  v  a 2  s  . co m*/
    HttpSession session = req.getSession(true);
    session.setAttribute(AUTH_KEY, true);
    session.setAttribute(AUTH_USER_ID, userId);
    session.setAttribute(AUTH_USER_IS_ANONYMOUS, isUserAnonymous);
    session.setAttribute(AUTH_LOCKED, false);
}

From source file:com.sifcoapp.report.util.ReportConfigUtil.java

private static void setCompileTempDir(HttpServletRequest request, String uri) {
    System.setProperty("jasper.reports.compile.temp",
            request.getSession().getServletContext().getRealPath(uri));
}

From source file:edu.stanford.muse.webapp.Accounts.java

/** adds alternateEmailAddrs if specified in the request to the session. alternateEmailAddrs are simply appended to. */
public static void updateUserInfo(HttpServletRequest request) {
    HttpSession session = request.getSession();

    String ownerName = request.getParameter("name");
    if (!Util.nullOrEmpty(ownerName))
        session.setAttribute("ownerName", ownerName);

    String archiveTitle = request.getParameter("archiveTitle");
    if (!Util.nullOrEmpty(archiveTitle))
        session.setAttribute("archiveTitle", archiveTitle);

    String alt = request.getParameter("alternateEmailAddrs");
    if (Util.nullOrEmpty(alt))
        return;//w  w  w .  j a  v  a2s .  c o m

    String sessionAlt = (String) JSPHelper.getSessionAttribute(session, "alternateEmailAddrs");
    if (Util.nullOrEmpty(sessionAlt))
        session.setAttribute("alternateEmailAddrs", alt); // this will be removed when we fetch and index email
    else
        session.setAttribute("alternateEmailAddrs", sessionAlt + " " + alt);
    // could also uniquify the emailAddrs here
}

From source file:com.swiftcorp.portal.common.util.WebUtils.java

public static int getUserWorkingLevel(HttpServletRequest request) {

    int workingLevel = GlobalConstants.SYSTEM_LEVEL;

    HttpSession session = request.getSession();
    Integer ulObj = (Integer) session.getAttribute(SESSION_KEYS.WORKING_LEVEL);
    if (ulObj != null) {
        workingLevel = ulObj.intValue();
    }//from ww w . j av  a  2 s  . co m
    return workingLevel;
}

From source file:com.salesmanager.core.util.CategoryUtil.java

/**
 * Determine if a catagory has products/* w w  w.j a v a 2  s. co m*/
 * 
 * @param req
 * @param categoryid
 * @return
 */
public static boolean categoryHasItems(HttpServletRequest req, long categoryid) {

    Map reccount = (Map) req.getSession().getAttribute("PRODUCTCOUNT");
    if (reccount != null) {
        Integer count = (Integer) reccount.get(categoryid);
        if (count == null)
            return false;
        return true;
    } else {
        return false;
    }

}