Example usage for javax.servlet.http HttpSession getAttribute

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

Introduction

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

Prototype

public Object getAttribute(String name);

Source Link

Document

Returns the object bound with the specified name in this session, or null if no object is bound under the name.

Usage

From source file:br.com.manish.ahy.web.util.WebUtil.java

public static Object getSessionAttribute(HttpServletRequest req, String attribute) {
    HttpSession session = req.getSession(true);
    return session.getAttribute(attribute);
}

From source file:com.surfs.storage.web.utils.WebUtils.java

public static String getCrrentDataCenterKey(HttpSession session) {
    /*return "uspod1/uscluster2";*/
    Object dataCenterKey = session.getAttribute("dataCenterKey");
    return dataCenterKey != null ? dataCenterKey.toString() : null;
}

From source file:com.surfs.storage.web.utils.WebUtils.java

public static String getCrrentDataCenterName(HttpSession session) {
    /*return "uspod1/uscluster2";*/
    Object dataCenterName = session.getAttribute("dataCenterName");
    return dataCenterName != null ? dataCenterName.toString() : null;
}

From source file:org.tsm.concharto.auth.AuthHelper.java

public static boolean isUserInSession(HttpServletRequest request) {
    HttpSession session = request.getSession();
    return (null != session.getAttribute(AuthConstants.SESSION_AUTH_USERNAME));
}

From source file:org.freeeed.search.web.session.SessionContext.java

public static SolrSessionObject getSolrSession() {
    HttpServletRequest curRequest = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes())
            .getRequest();/* ww w.ja va  2 s .  co m*/
    HttpSession session = curRequest.getSession();
    SolrSessionObject solrSession = (SolrSessionObject) session
            .getAttribute(WebConstants.WEB_SESSION_SOLR_OBJECT);
    return solrSession;
}

From source file:org.openmrs.module.rwandaprimarycare.PrimaryCareWebLogic.java

public static Location getCurrentLocation(HttpSession session) {

    Location loc = (Location) session.getAttribute(PrimaryCareConstants.SESSION_ATTRIBUTE_WORKSTATION_LOCATION);
    if (loc == null) {
        loc = Context.getLocationService().getDefaultLocation();
    }//from  ww w .j av  a  2 s .co m
    if (loc == null) {
        log.warn("Cannot find a current or default location");
    }
    return loc;
}

From source file:com.orig.gls.web.category.Categoryw.java

public static void handleGoCategory(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    HttpSession session = request.getSession(false);
    if ((String) session.getAttribute("uname") != null) {
        session.setAttribute("catfunc", request.getParameter("function"));
        session.setAttribute("categorytype", request.getParameter("categorytype"));
        session.setAttribute("content_page", "categories/mCategories_b.jsp");
    } else {/*from w  w  w .  j a v a2s  .  c  om*/
        session.setAttribute("content_page", "sessionexp.jsp");
    }
    response.sendRedirect("index.jsp");
}

From source file:org.tec.webapp.web.ControllerUtils.java

/**
 * clear the current user/*w  w w . j  av  a 2s .  com*/
 * @param session the current session
 * @return the current user
 */
public static UserBean clearCurrentUser(HttpSession session) {
    UserBean u = (UserBean) session.getAttribute(CURRENT_USER_KEY);

    if (u != null) {
        session.removeAttribute(CURRENT_USER_KEY);
    }

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("clearing current user " + u);
    }

    return u;
}

From source file:com.miserablemind.butter.helpers.Utilities.java

/**
 * Gets {@link SecurityContext} From Active HTTP Session.
 *
 * @return {@link SecurityContext}/* ww w.  j a va2  s.  co  m*/
 */
public static SecurityContext getSecurityContext() {
    HttpSession session = Utilities.getSession();
    return (SecurityContext) session.getAttribute("SPRING_SECURITY_CONTEXT");
}

From source file:br.com.manish.ahy.web.util.JSFUtil.java

public static Object getSessionAttribute(String attribute) {
    FacesContext context = FacesContext.getCurrentInstance();
    HttpSession session = (HttpSession) context.getExternalContext().getSession(true);
    return session.getAttribute(attribute);
}