/** * Removes the specified session attribute. * * @param key the name of the attribute to remove. * @return the value that was removed or <tt>null</tt> if the value was not found (and hence, not removed). */ public Object remove(Object key) { if (session == null) { return null; } synchronized (session) { entries = null; Object value = get(key); session.removeAttribute(key.toString()); return value; } } }
/** * Saves an attribute in the session. * * @param key the name of the session attribute. * @param value the value to set. * @return the object that was just set. */ public Object put(Object key, Object value) { synchronized (this) { if (session == null) { session = request.getSession(true); } } synchronized (session) { entries = null; session.setAttribute(key.toString(), value); return get(key); } }
/** * Invalidate this session if it is marked to be invalidated from previous request. * * @see com.opensymphony.xwork.interceptor.AroundInterceptor#before(com.opensymphony.xwork.ActionInvocation) */ protected void before(ActionInvocation invocation) throws Exception { SessionMap sessionMap = (SessionMap) invocation.getInvocationContext().get(ActionContext.SESSION); if (sessionMap.containsKey(key) && sessionMap.get(key).equals("true")) { if (LOG.isDebugEnabled()) LOG.debug("found marker in session indicating this is the 'next request', session should be invalidated"); sessionMap.invalidate(); LOG.info("session invalidated"); } } }