本文整理汇总了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;
}
示例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);
}
}
}
}
}
示例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();
}
}
示例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);
}
}
}
示例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();
}
}
示例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;
}
示例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());
}
示例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");
}
示例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();
}
}
示例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;
}
示例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()) {
}
}
示例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);
}
}
}
示例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";
}
示例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);
}
示例15: clearSession
import javax.servlet.http.HttpSession; //导入方法依赖的package包/类
@Override
public void clearSession(String customiseSessionID, HttpSession session, ToolAccessMode mode) {
if (mode.isAuthor()) {
session.removeAttribute(customiseSessionID);
}
}