当前位置: 首页>>代码示例>>Java>>正文


Java HttpSession.removeAttribute方法代码示例

本文整理汇总了Java中javax.servlet.http.HttpSession.removeAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java HttpSession.removeAttribute方法的具体用法?Java HttpSession.removeAttribute怎么用?Java HttpSession.removeAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.http.HttpSession的用法示例。


在下文中一共展示了HttpSession.removeAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeSessionAttribute

import javax.servlet.http.HttpSession; //导入方法依赖的package包/类
/**
 * Removes an attribute from an HttpSession
 * @param cn Name of the application hosting the session from which the
 *           attribute is to be removed
 * @param sessionId
 * @param attributeName
 * @param smClient  StringManager for the client's locale
 * @return true if there was an attribute removed, false otherwise
 * @throws IOException 
 */
protected boolean removeSessionAttribute(ContextName cn, String sessionId,
        String attributeName, StringManager smClient) throws IOException {
    HttpSession session =
        getSessionForNameAndId(cn, sessionId, smClient).getSession();
    if (null == session) {
        // Shouldn't happen, but let's play nice...
        if (debug >= 1) {
            log("WARNING: can't remove attribute '" + attributeName + "' for null session " + sessionId);
        }
        return false;
    }
    boolean wasPresent = (null != session.getAttribute(attributeName));
    try {
        session.removeAttribute(attributeName);
    } catch (IllegalStateException ise) {
        if (debug >= 1) {
            log("Can't remote attribute '" + attributeName + "' for invalidated session id " + sessionId);
        }
    }
    return wasPresent;
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:32,代码来源:HTMLManagerServlet.java

示例2: clearSession

import javax.servlet.http.HttpSession; //导入方法依赖的package包/类
private void clearSession()
{
	final HttpSession session = getCurrentSession(false);
	if( session != null )
	{
		synchronized( session )
		{
			final String keyPrefix = getKeyPrefix().toString();

			for( Enumeration<?> e = session.getAttributeNames(); e.hasMoreElements(); )
			{
				String name = (String) e.nextElement();
				if( name.startsWith(keyPrefix) )
				{
					session.removeAttribute(name);
				}
			}
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:21,代码来源:UserSessionServiceImpl.java

示例3: chearCache

import javax.servlet.http.HttpSession; //导入方法依赖的package包/类
/**
 * 清除所有session
 * @param session
 * @throws Exception
 */
public static void chearCache(HttpSession session) throws Exception {
	try {
		Enumeration enumeration = session.getAttributeNames();
		while (enumeration.hasMoreElements()) {
			String key = enumeration.nextElement().toString();
			log.info("WebUtil chearCache key:{}", key);
			session.removeAttribute(key);
			log.info("WebUtil removeAttribute key:{}", key);
		}
	} catch (Exception e) {
		log.error("chearCache error {}", e.getMessage());
		e.printStackTrace();
	}
}
 
开发者ID:iunet,项目名称:iunet-blog,代码行数:20,代码来源:WebUtil.java

示例4: sessionDestroyed

import javax.servlet.http.HttpSession; //导入方法依赖的package包/类
/** Notification that a session was invalidated.
 * This method will remove all attrributes from the session.
 * @param se the notification event.
 */
public void sessionDestroyed(HttpSessionEvent se) {
    if (log.isDebugEnabled())
        log.debug("Session Destroyed " + se.getSession(), new Exception("This exception is created merely to record the current stacktrace on a JaffaHttpSessionListener.sessionDestroyed()"));
    HttpSession session = se.getSession();
    Enumeration enumeration = session.getAttributeNames();
    if (enumeration != null) {
        while (enumeration.hasMoreElements()) {
            String attributeName = (String) enumeration.nextElement();
            session.removeAttribute(attributeName);
            if (log.isDebugEnabled())
                log.debug("Removed an existing attribute from the newly acquired Session object: " + attributeName);
        }
    }
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:19,代码来源:JaffaHttpSessionListener.java

示例5: invalidateSession

import javax.servlet.http.HttpSession; //导入方法依赖的package包/类
/**
 * Remove the user from the session and expire the session - after failed ticket auth.
 * 
 * @param req HttpServletRequest
 */
protected void invalidateSession(HttpServletRequest req)
{
    HttpSession session = req.getSession(false);
    if (session != null)
    {
        setExternalAuth(session, false);
        session.removeAttribute(getUserAttributeName());
        session.invalidate();
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:16,代码来源:BaseAuthenticationFilter.java

示例6: invalidateSession

import javax.servlet.http.HttpSession; //导入方法依赖的package包/类
/**
 * Invalidate the current session
 * 
 * @return the current HTTP servlet request
 */
private HttpServletRequest invalidateSession() {

    HttpServletRequest request = getRequest();
    HttpSession session = request.getSession(false);
    if (session != null) {
        try {

            String mId = getMarketplaceId();

            session.removeAttribute(Constants.SESS_ATTR_USER);
            getSessionService().deletePlatformSession(session.getId());

            SessionListener.cleanup(session);

            if (mId != null) {
                HttpSession currentSession = request.getSession(true);
                currentSession.setAttribute(
                        Constants.REQ_PARAM_MARKETPLACE_ID, mId);
            }
        } catch (SaaSSystemException e) {
            if (!isMarketplaceSet(request)) {
                throw e;
            }
        }
    }

    return request;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:34,代码来源:UserBean.java

示例7: save

import javax.servlet.http.HttpSession; //导入方法依赖的package包/类
public void save(HttpSession session) {
    if (getSubjectArea()==null)
        session.removeAttribute("Classes.subjectArea");
    else
        session.setAttribute("Classes.subjectArea", getSubjectArea());
    if (getCourseNumber()==null)
        session.removeAttribute("Classes.courseNumber");
    else
        session.setAttribute("Classes.courseNumber", getCourseNumber());
    if (getSession()==null)
        session.removeAttribute("Classes.session");
    else
        session.setAttribute("Classes.session", getSession());
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:15,代码来源:ClassesForm.java

示例8: logout

import javax.servlet.http.HttpSession; //导入方法依赖的package包/类
/**
 * Log out
 */
@Override
public void logout() {
	HttpServletRequest request = this.getThreadLocalRequest();
	HttpSession session = request.getSession();
	session.removeAttribute("username");
	session.removeAttribute("email");
	session.removeAttribute("serial");
}
 
开发者ID:ICT-BDA,项目名称:EasyML,代码行数:12,代码来源:AccountServiceImpl.java

示例9: close

import javax.servlet.http.HttpSession; //导入方法依赖的package包/类
public void close(CloseReason closeReason) throws IOException
{
    HttpSession httpSession = (HttpSession) session.getUserProperties().get(HttpSession.class.getName());
    httpSession.removeAttribute(WObject.class.getName());
    httpSession.removeAttribute(PorterOfFun.class.getName());
    httpSession.removeAttribute(WebSocket.class.getName());
    if (closeReason != null)
    {
        session.close(closeReason);
    } else
    {
        session.close();
    }
}
 
开发者ID:gzxishan,项目名称:OftenPorter,代码行数:15,代码来源:WS.java

示例10: getUploads

import javax.servlet.http.HttpSession; //导入方法依赖的package包/类
@Override
public Map<String, List<String>> getUploads(HttpServletRequest req) {
  Map<String, List<String>> response = null;
  HttpSession session = req.getSession();
  Map<String, String> blobs = (Map<String, String>) session.getAttribute("blobs");
  for (String name : blobs.keySet()) {
    response = new HashMap<String, List<String>>(1);
    List<String> keys = new ArrayList<String>(1);
    keys.add(blobs.get(name));
    response.put(name, keys);
  }
  session.removeAttribute("blobs");
  return response;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:15,代码来源:CommonBlobStoreService.java

示例11: clearSession

import javax.servlet.http.HttpSession; //导入方法依赖的package包/类
@Override
   public void clearSession(String customiseSessionID, HttpSession session, ToolAccessMode mode) {

if (mode.isAuthor()) {
    session.removeAttribute(customiseSessionID);
}

if (mode.isTeacher()) {

}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:ClearSessionAction.java

示例12: setSessionAttribute

import javax.servlet.http.HttpSession; //导入方法依赖的package包/类
/**
 * Set the session attribute with the given name to the given value.
 * Removes the session attribute if value is null, if a session existed at all.
 * Does not create a new session if not necessary!
 * @param request current HTTP request
 * @param name the name of the session attribute
 * @param value the value of the session attribute
 */
public static void setSessionAttribute(HttpServletRequest request, String name, Object value) {
	Assert.notNull(request, "Request must not be null");
	if (value != null) {
		request.getSession().setAttribute(name, value);
	}
	else {
		HttpSession session = request.getSession(false);
		if (session != null) {
			session.removeAttribute(name);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:WebUtils.java

示例13: loginout

import javax.servlet.http.HttpSession; //导入方法依赖的package包/类
@RequestMapping("loginout.do")
	public String loginout(HttpServletRequest request,HttpServletResponse response){
	//���session
	HttpSession session=request.getSession();
	response.setHeader("Cache-Control","no-cache");
   	response.setHeader("Cache-Control","no-store"); 
   	response.setDateHeader("Expires", 0); 
   	response.setHeader("Pragma","no-cache");
   	session.removeAttribute("username");
   	session.removeAttribute("employee");
	session.invalidate();
	return "redirect:login.jsp";
}
 
开发者ID:liberliushahe,项目名称:attendance,代码行数:14,代码来源:LoginAction.java

示例14: handleRequestInternal

import javax.servlet.http.HttpSession; //导入方法依赖的package包/类
@Override
protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response)
        throws Exception {
    // get CAS ticket
    final String ticket = request.getParameter(OAuthConstants.TICKET);
    logger.debug("{} : {}", OAuthConstants.TICKET, ticket);

    // retrieve callback url from session
    final HttpSession session = request.getSession();
    String callbackUrl = (String) session.getAttribute(OAuthConstants.OAUTH20_CALLBACKURL);
    logger.debug("{} : {}", OAuthConstants.OAUTH20_CALLBACKURL, callbackUrl);
    session.removeAttribute(OAuthConstants.OAUTH20_CALLBACKURL);

    if (StringUtils.isBlank(callbackUrl)) {
        logger.error("{} is missing from the session and can not be retrieved.", OAuthConstants.OAUTH20_CALLBACKURL);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }
    // and state
    final String state = (String) session.getAttribute(OAuthConstants.OAUTH20_STATE);
    logger.debug("{} : {}", OAuthConstants.OAUTH20_STATE, state);
    session.removeAttribute(OAuthConstants.OAUTH20_STATE);

    // return callback url with code & state
    callbackUrl = OAuthUtils.addParameter(callbackUrl, OAuthConstants.CODE, ticket);
    if (state != null) {
        callbackUrl = OAuthUtils.addParameter(callbackUrl, OAuthConstants.STATE, state);
    }
    logger.debug("{} : {}", OAuthConstants.OAUTH20_CALLBACKURL, callbackUrl);

    final Map<String, Object> model = new HashMap<String, Object>();
    model.put("callbackUrl", callbackUrl);

    // retrieve service name from session
    final String serviceName = (String) session.getAttribute(OAuthConstants.OAUTH20_SERVICE_NAME);
    logger.debug("serviceName : {}", serviceName);
    model.put("serviceName", serviceName);
    return new ModelAndView(OAuthConstants.CONFIRM_VIEW, model);
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:39,代码来源:OAuth20CallbackAuthorizeController.java

示例15: clearSession

import javax.servlet.http.HttpSession; //导入方法依赖的package包/类
@Override
   public void clearSession(String customiseSessionID, HttpSession session, ToolAccessMode mode) {
if (mode.isAuthor()) {
    session.removeAttribute(customiseSessionID);
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:ClearSessionAction.java


注:本文中的javax.servlet.http.HttpSession.removeAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。