List of usage examples for javax.servlet.http HttpSession getAttribute
public Object getAttribute(String name);
null
if no object is bound under the name. From source file:info.magnolia.cms.util.Resource.java
/** * Check for preview mode./*w ww . j a v a2 s. c o m*/ * @param req HttpServletRequest as received in JSP or servlet * @return boolean , true if preview is enabled */ public static boolean showPreview(HttpServletRequest req) { // first check if its set in request scope if (req.getParameter(MGNL_PREVIEW_ATTRIBUTE) != null) { return BooleanUtils.toBoolean(req.getParameter(MGNL_PREVIEW_ATTRIBUTE)); } else { HttpSession httpsession = req.getSession(false); if (httpsession != null) { return BooleanUtils.toBoolean((Boolean) httpsession.getAttribute(MGNL_PREVIEW_ATTRIBUTE)); } } return false; }
From source file:com.facetime.communication.activemq.AmqConsumer.java
/** * @return the web client for the current HTTP session or null if there is * not a web client created yet/*from www. j av a 2 s . c o m*/ */ public static AmqConsumer getWebClient(HttpSession session) { return (AmqConsumer) session.getAttribute(WEB_CLIENT_ATTRIBUTE); }
From source file:edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.java
/** * Get the bean from the session, or null if there is no bean. */// ww w . java 2 s .co m private static LoginProcessBean getBeanFromSession(HttpServletRequest request) { HttpSession session = request.getSession(false); if (session == null) { return null; } Object bean = session.getAttribute(SESSION_ATTRIBUTE); if (bean == null) { return null; } if (!(bean instanceof LoginProcessBean)) { log.warn("Tried to get login process bean, but found an instance of " + bean.getClass().getName() + ": " + bean); return null; } return (LoginProcessBean) bean; }
From source file:edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.java
public static ModelAccess on(HttpSession session) { Object o = session.getAttribute(ATTRIBUTE_NAME); if (o instanceof ModelAccess) { return (ModelAccess) o; } else {// w w w.j a va 2 s .co m ModelAccess parent = on(session.getServletContext()); ModelAccess ma = new ModelAccess(Scope.SESSION, parent); session.setAttribute(ATTRIBUTE_NAME, ma); return ma; } }
From source file:org.jbpcc.admin.jsf.JsfUtil.java
/** * Convenience method for retrieving session variables. * // w w w .ja v a 2 s .co m * @param session * the session to retrieve it from; cannot be <code>null</code> * @param sessionObjectKey * the session object key; cannot be <code>null</code> */ public static Object getFromSession(HttpSession session, SessionObjectKey sessionObjectKey) { return session.getAttribute(sessionObjectKey.getKey()); }
From source file:com.gdo.project.model.SessionStcl.java
/** * Retrieves the session stencil from HTTP session. * // ww w .j a va 2 s. c o m * @param stclContext * the stencil context. * @return the session stencil. */ public static Stcl getSessionStcl(StclContext stclContext) { HttpSession session = stclContext.getSession(); SessionListener listener = (SessionListener) session.getAttribute(SESSION_KEY); return (listener != null) ? listener.getSessionStcl() : null; }
From source file:com.brienwheeler.web.spring.security.SecurityUtils.java
public static User getLoggedInUser(HttpSession session, IUserService userService) { ValidationUtils.assertNotNull(session, "session cannot be null"); ValidationUtils.assertNotNull(userService, "userService cannot be null"); long userId = ensureLoggedInUserId(); Object attribute = session.getAttribute(LOGGED_IN_USER); if ((attribute instanceof User) && (((User) attribute).getId() == userId)) return (User) attribute; User user = userService.findById(new DbId<User>(User.class, userId)); if (user == null) throw new IllegalStateException("logged in user id not found in database"); session.setAttribute(LOGGED_IN_USER, user); return user;/* w ww. ja va 2 s . c om*/ }
From source file:org.jbpcc.admin.jsf.JsfUtil.java
/** * Convenience method for retrieving session variables. * /* w ww. j a va 2s. co m*/ * @param sessionObjectKey * the session object key; cannot be <code>null</code> */ public static Object getFromSession(SessionObjectKey sessionObjectKey) { FacesContext ctx = getCurrentFacesContext(); HttpSession session = (HttpSession) ctx.getExternalContext().getSession(true); return session.getAttribute(sessionObjectKey.getKey()); }
From source file:be.fedict.eid.applet.service.impl.handler.HelloMessageHandler.java
public static String getClientLanguage(HttpSession httpSession) { String clientLanguage = (String) httpSession.getAttribute(CLIENT_LANGUAGE_SESSION_ATTRIBUTE); return clientLanguage; }
From source file:app.navigate.entity.EntityRedirectorPage.java
public static EntitySubtypeRedirectInfo getEntitySubtypeRedirectInfo(NavigationContext nc, Object id) { HttpSession session = nc.getHttpRequest().getSession(); EntitySubtypeRedirectInfo esri = (EntitySubtypeRedirectInfo) session.getAttribute(SESSATTRNAME_ESRI); session.removeAttribute(SESSATTRNAME_ESRI); // get rid of it so it's not hanging around for next call if (esri != null && esri.getId().equals(id)) return esri; else// w ww . j a v a 2 s.c o m return null; }