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:br.com.manish.ahy.web.util.WebUtil.java

public static void setSessionAttribute(HttpServletRequest req, String attribute, Object value) {
    log.debug("Setting session attribute: " + attribute + " - " + value);
    HttpSession session = req.getSession(true);
    session.setAttribute(attribute, value);
}

From source file:edu.cornell.mannlib.vitro.webapp.beans.DisplayMessage.java

/**
 * Store this message on the session. This will overwrite any previously
 * stored message.//  ww w. j a  v a 2  s.  c om
 */
public static void setMessage(HttpSession session, String message) {
    session.setAttribute(ATTRIBUTE_NAME, message);
    log.debug("Set message: '" + message + "'");
}

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

public static void handleMaintainCategory(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    HttpSession session = request.getSession(false);
    session.setAttribute("catadded", false);
    session.setAttribute("catexists", false);
    if ((String) session.getAttribute("uname") != null) {
        String function = request.getParameter("function");
        String categorytype = request.getParameter("categorytype");
        String categorycode = request.getParameter("categorycode");
        String categoryvalue = request.getParameter("categoryvalue");
        switch (function) {
        case "ADD":
            if (!Category.categoryExists(categorycode, categorytype)) {
                Category.addCategories(Bank.getBankId(), categorycode, categorytype, categoryvalue, new Date(),
                        (String) session.getAttribute("uname"), new Date(),
                        (String) session.getAttribute("uname"));
                session.setAttribute("catadded", true);
                session.setAttribute("content_page", "categories/mCategories_a.jsp");
            } else {
                session.setAttribute("catexists", true);
                session.setAttribute("content_page", "categories/mCategories_b.jsp");
            }//from www  . j ava 2 s.co  m
            break;
        }
    } else {
        session.setAttribute("content_page", "sessionexp.jsp");
    }
    response.sendRedirect("index.jsp");
}

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

public static void setSessionAttribute(String attribute, Object value) {
    log.debug("Setting session attribute: " + attribute + " - " + value);
    FacesContext context = FacesContext.getCurrentInstance();
    HttpSession session = (HttpSession) context.getExternalContext().getSession(true);
    session.setAttribute(attribute, value);
}

From source file:cn.vlabs.umt.ui.UMTContext.java

public static void saveRoles(HttpSession session, UMTRole[] roles) {
    session.setAttribute(Attributes.ROLE, roles);
}

From source file:com.fruit.core.util.IWebUtils.java

/**
 * ?//from w  w  w  . j a  va 2s.c  o  m
 * @author eason
 * @param HttpSession
 * @param user
 */
public static void setCurrentLoginSysUserToSession(HttpSession httpSession, SysUser sysUser) {
    httpSession.setAttribute("sysUser", sysUser);
}

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 {/*w  ww  . jav a2s .  c  om*/
        session.setAttribute("content_page", "sessionexp.jsp");
    }
    response.sendRedirect("index.jsp");
}

From source file:edu.cornell.mannlib.vedit.beans.LoginStatusBean.java

/**
 * Attach this bean to the session - this means you are logged in.
 *///from w w w. j a v  a  2s  .  com
public static void setBean(HttpSession session, LoginStatusBean lsb) {
    session.setAttribute(ATTRIBUTE_NAME, lsb);
}

From source file:net.shibboleth.idp.oidc.util.OIDCUtils.java

/**
 * Put session attribute./*from   w ww.  j  ava2 s  .com*/
 *
 * @param request   the request
 * @param parameter the parameter
 * @param value     the value
 */
public static void putSessionAttribute(final HttpServletRequest request, final String parameter,
        final Object value) {
    final HttpSession session = request.getSession();
    session.setAttribute(parameter, value);
}

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

public static void lock(HttpServletRequest req, HttpServletResponse resp) {
    HttpSession session = req.getSession(true);
    session.setAttribute(AUTH_LOCKED, true);
}