Example usage for javax.servlet.http HttpSession setAttribute

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

Introduction

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

Prototype

public void setAttribute(String name, Object value);

Source Link

Document

Binds an object to this session, using the name specified.

Usage

From source file:com.hangum.tadpole.session.manager.SessionManager.java

/**
 * Update session information.<br>
 * <br>//  w w  w  .ja  v a2  s .co m
 * Session uses the information in multiple places(preference, user info etc.). 
 * So when updating the information stored in the Session, 
 * you must update the information given session.
 * 
 * @param key Session Attribute name
 * @param value Object
 */
public static void updateSessionAttribute(String key, Object value) {
    HttpSession sStore = RWT.getRequest().getSession();
    sStore.setAttribute(key, value);
}

From source file:com.hangum.tadpole.session.manager.SessionManager.java

/**
 * set password/*from  w  w w. ja  v a 2  s  .  c o  m*/
 * 
 * @param strPasswd
 */
public static void setPassword(String strPasswd) {
    HttpSession sStore = RWT.getRequest().getSession();
    sStore.setAttribute(NAME.LOGIN_PASSWORD.name(), strPasswd);
}

From source file:com.hangum.tadpole.session.manager.SessionManager.java

/**
 *  ? ??  ? ?? . /*from w w  w . j  a  va  2 s .  c om*/
 */
public static void setUserAllPreferenceData(Map<String, Object> mapUserInfo) {
    HttpSession sStore = RWT.getRequest().getSession();
    sStore.setAttribute(NAME.USER_INFO_DATA.name(), mapUserInfo);
}

From source file:com.hangum.tadpole.session.manager.SessionManager.java

/**
 * logout  .//from ww  w .  j  ava 2s  . c om
 */
public static void logout() {
    HttpServletRequest request = RWT.getRequest();
    try {
        HttpSession sStore = request.getSession();
        sStore.setAttribute(NAME.USER_SEQ.toString(), 0);
        sStore.invalidate();
    } catch (Throwable e) {
        // ignore exception
    }

    // fixed https://github.com/hangum/TadpoleForDBTools/issues/708
    // ps - ? session id    ? ? ?. - hangum
    String[] arryRequestURL = StringUtils.split(request.getRequestURL().toString(), ";");
    String browserText = MessageFormat.format("parent.window.location.href = \"{0}\";", arryRequestURL[0]);
    JavaScriptExecutor executor = RWT.getClient().getService(JavaScriptExecutor.class);
    executor.execute("setTimeout('" + browserText + "', 100)");

}

From source file:com.hangum.tadpole.session.manager.SessionManager.java

/**
 * ? session? ?/*from   w  ww.  j  a v  a  2  s .c  om*/
 * 
 * @param userDao
 * @param loginType
 * @param ip
 */
public static void addSession(UserDAO userDao, String loginType, String ip) {
    HttpSession sStore = RWT.getRequest().getSession();

    sStore.setAttribute(NAME.LOGIN_IP_TYPE.name(), loginType);
    sStore.setAttribute(NAME.LOGIN_IP.name(), ip);
    sStore.setAttribute(NAME.REPRESENT_ROLE_TYPE.name(), userDao.getRole_type());
    sStore.setAttribute(NAME.USER_SEQ.name(), userDao.getSeq());
    sStore.setAttribute(NAME.LOGIN_EMAIL.name(), userDao.getEmail());
    sStore.setAttribute(NAME.LOGIN_PASSWORD.name(),
            CipherManager.getInstance().decryption(userDao.getPasswd()));
    sStore.setAttribute(NAME.LOGIN_NAME.name(), userDao.getName());
    sStore.setAttribute(NAME.IS_REGIST_DB.name(), userDao.getIs_regist_db());
    sStore.setAttribute(NAME.LANGUAGE.name(), userDao.getLanguage());
    sStore.setAttribute(NAME.TIMEZONE.name(), userDao.getTimezone());

    sStore.setAttribute(NAME.IS_SHARED_DB.name(), userDao.getIs_shared_db());
    sStore.setAttribute(NAME.LIMIT_ADD_DB_CNT.name(), userDao.getLimit_add_db_cnt());
    sStore.setAttribute(NAME.SERVICE_END.name(), userDao.getService_end());

    sStore.setAttribute(NAME.PERSPECTIVE.name(), "default");

    sStore.setAttribute(NAME.USE_OTP.name(), userDao.getUse_otp());
    sStore.setAttribute(NAME.OTP_SECRET_KEY.name(), userDao.getOtp_secret());

    sStore.setAttribute(NAME.UNLOCK_DB_LIST.name(), new ArrayList<Integer>());
}

From source file:edu.cornell.mannlib.vivo.orcid.controller.OrcidConfirmationState.java

static OrcidConfirmationState fetch(HttpServletRequest req) {
    HttpSession session = req.getSession();
    Object o = session.getAttribute(ATTRIBUTE_NAME);
    if (o instanceof OrcidConfirmationState) {
        return (OrcidConfirmationState) o;
    } else {/* w w w  . java 2  s .  c  om*/
        OrcidConfirmationState ocs = new OrcidConfirmationState();
        session.setAttribute(ATTRIBUTE_NAME, ocs);
        return ocs;
    }
}

From source file:com.facetime.communication.activemq.AmqConsumer.java

/**
 * Helper method to get the client for the current session, lazily creating
 * a client if there is none currently//from  w  ww.j av  a 2 s  .  c om
 * 
 * @param request
 *            is the current HTTP request
 * @return the current client or a newly creates
 */
public static AmqConsumer getWebClient(HttpServletRequest request) {
    HttpSession session = request.getSession(true);
    AmqConsumer client = getWebClient(session);
    if (client == null || client.isClosed()) {
        client = AmqConsumer.createWebClient(request);
        session.setAttribute(WEB_CLIENT_ATTRIBUTE, client);
    }

    return client;
}

From source file:com.formkiq.core.webflow.FlowManager.java

/**
 * Gets the Next WebFlow Session Id.//w w w  .  java  2s  .  c  o  m
 * @param req {@link HttpServletRequest}
 * @return int
 */
private static int getNextWebFlowSessionId(final HttpServletRequest req) {

    int sessionId = 1;
    HttpSession session = req.getSession();
    Object sessionOb = session.getAttribute(WEBFLOW_SESSION_ID);

    if (sessionOb != null) {
        try {
            sessionId = Integer.parseInt(sessionOb.toString()) + 1;
        } catch (NumberFormatException e) {
            sessionId = 1;
        }
    }

    session.setAttribute(WEBFLOW_SESSION_ID, String.valueOf(sessionId));

    return sessionId;
}

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

/**
 * get the currently logged on user//from ww w .ja v  a 2  s  .c o m
 * @param session the current http session
 * @param userSvc the user service
 * @return the current user
 */
public static UserBean getCurrentUser(HttpSession session, UserSvc userSvc) {
    UserBean u = (UserBean) session.getAttribute(CURRENT_USER_KEY);

    if (u == null) {
        SecurityContext secctx = (SecurityContext) session.getAttribute(SPRING_SECURITY_CONTEXT_KEY);

        String currentUser = ((org.springframework.security.core.userdetails.User) secctx.getAuthentication()
                .getPrincipal()).getUsername();

        u = userSvc.getUser(currentUser);

        session.setAttribute(CURRENT_USER_KEY, u);
    }

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

    return u;
}

From source file:fr.paris.lutece.portal.web.PortalJspBean.java

/**
 * Set the upload filter site next url//  w  w w. j  av a  2 s .c  o m
 * @param request the HTTP request
 */
public static void setUploadFilterSiteNextUrl(HttpServletRequest request) {
    String strNextUrl = request.getRequestURI();
    UrlItem url = new UrlItem(strNextUrl);
    Enumeration enumParams = request.getParameterNames();

    while (enumParams.hasMoreElements()) {
        String strParamName = (String) enumParams.nextElement();
        url.addParameter(strParamName, request.getParameter(strParamName));
    }

    HttpSession session = request.getSession(true);
    session.setAttribute(ATTRIBUTE_UPLOAD_FILTER_SITE_NEXT_URL, url.getUrl());
}