本文整理汇总了Java中javax.servlet.http.HttpSessionBindingListener.valueBound方法的典型用法代码示例。如果您正苦于以下问题:Java HttpSessionBindingListener.valueBound方法的具体用法?Java HttpSessionBindingListener.valueBound怎么用?Java HttpSessionBindingListener.valueBound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.http.HttpSessionBindingListener
的用法示例。
在下文中一共展示了HttpSessionBindingListener.valueBound方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAttribute
import javax.servlet.http.HttpSessionBindingListener; //导入方法依赖的package包/类
/**
* Binds an object to this session, using the name specified. If an object of
* the same name is already bound to the session, the object is replaced.
* @param name The name to which the object is bound; cannot be null.
* @param value The object to be bound.
*/
public void setAttribute(String name, Object value) {
if (!isValid())
throw new IllegalStateException(
"Method is called on an invalidated session");
if (value == null) removeAttribute(name);
else {
attributes.put(name, value);
try {
HttpSessionBindingListener listener = (HttpSessionBindingListener) value;
listener.valueBound(new HttpSessionBindingEvent(this, name, value));
listener.notifyAll();
}
catch (ClassCastException e) { }
}
}
示例2: afterBound
import javax.servlet.http.HttpSessionBindingListener; //导入方法依赖的package包/类
protected void afterBound(String s, Object o) {
if (o instanceof HttpSessionBindingListener) {
HttpSessionBindingListener listener = (HttpSessionBindingListener) o;
HttpSessionBindingEvent event = new HttpSessionBindingEvent(this, s, o);
listener.valueBound(event);
}
}