public class SessionImpl extends Object implements javax.servlet.http.HttpSession
HttpSession接口。
注意,每个request均会创建独立的session对象,此对象本身不是线程安全的,不能被多线程同时访问。但其后备的session store是线程安全的。
| 构造器和说明 |
|---|
SessionImpl(String sessionID,
SessionWebContext webContext,
boolean isNew,
boolean create)
创建一个session对象。
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
assertAttributeNameForModification(String methodName,
String attrName)
检查将要更改的attr name是否合法。
|
protected void |
assertModel(String methodName)
确保model已经被取得,即session已被初始化。
|
protected void |
assertValid(String methodName)
确保session处于valid状态。
|
void |
clear()
清除一个session。
|
void |
commit(boolean commitHeaders)
提交session的内容,删除的、新增的、修改的内容被保存。
|
Object |
getAttribute(String name)
取得指定名称的attribute值。
|
Enumeration<String> |
getAttributeNames()
取得所有attributes的名称。
|
long |
getCreationTime()
取得session的创建时间。
|
String |
getId()
取得session ID。
|
long |
getLastAccessedTime()
取得最近访问时间。
|
int |
getMaxInactiveInterval()
取得session的最大不活动期限,超过此时间,session就会失效。
|
javax.servlet.ServletContext |
getServletContext()
取得当前session所属的servlet context。
|
javax.servlet.http.HttpSessionContext |
getSessionContext()
已过时。
no replacement
|
SessionModel |
getSessionModel()
取得当前的model。
|
SessionWebContext |
getSessionWebContext()
取得创建该session的request context。
|
Object |
getValue(String name)
已过时。
use getAttribute instead
|
String[] |
getValueNames()
已过时。
use getAttributeNames instead
|
void |
invalidate()
使一个session作废。
|
boolean |
isInvalidated()
判断当前session是否非法。
|
boolean |
isNew()
当前session是否为新的?
|
void |
putValue(String name,
Object value)
已过时。
use setAttribute instead
|
void |
removeAttribute(String name)
删除一个attribute。
|
void |
removeValue(String name)
已过时。
use removeAttribute instead
|
void |
setAttribute(String name,
Object value)
设置指定名称的attribute值。
|
void |
setMaxInactiveInterval(int maxInactiveInterval)
设置session的最大不活动期限,超过此时间,session就会失效。
|
String |
toString() |
public SessionImpl(String sessionID, SessionWebContext webContext, boolean isNew, boolean create)
public SessionWebContext getSessionWebContext()
public SessionModel getSessionModel()
public String getId()
getId 在接口中 javax.servlet.http.HttpSessionpublic long getCreationTime()
getCreationTime 在接口中 javax.servlet.http.HttpSessionIllegalStateException - 如果session已经invalidatedpublic long getLastAccessedTime()
getLastAccessedTime 在接口中 javax.servlet.http.HttpSessionIllegalStateException - 如果session已经invalidatedpublic int getMaxInactiveInterval()
getMaxInactiveInterval 在接口中 javax.servlet.http.HttpSessionpublic void setMaxInactiveInterval(int maxInactiveInterval)
setMaxInactiveInterval 在接口中 javax.servlet.http.HttpSessionmaxInactiveInterval - 不活动期限的秒数public javax.servlet.ServletContext getServletContext()
getServletContext 在接口中 javax.servlet.http.HttpSessionServletContext对象public Object getAttribute(String name)
getAttribute 在接口中 javax.servlet.http.HttpSessionname - attribute名称IllegalStateException - 如果session已经invalidatedpublic Enumeration<String> getAttributeNames()
getAttributeNames 在接口中 javax.servlet.http.HttpSessionIllegalStateException - 如果session已经invalidatedpublic void setAttribute(String name, Object value)
setAttribute 在接口中 javax.servlet.http.HttpSessionname - attribute名称value - attribute的值IllegalStateException - 如果session已经invalidatedIllegalArgumentException - 如果指定的attribute名称不被支持public void removeAttribute(String name)
removeAttribute 在接口中 javax.servlet.http.HttpSessionname - 要删除的attribute名称IllegalStateException - 如果session已经invalidatedpublic void invalidate()
invalidate 在接口中 javax.servlet.http.HttpSessionIllegalStateException - 如果session已经invalidatedpublic void clear()
IllegalStateException - 如果session已经invalidatedpublic boolean isInvalidated()
public boolean isNew()
isNew 在接口中 javax.servlet.http.HttpSessiontrueIllegalStateException - 如果session已经invalidatedprotected void assertModel(String methodName)
methodName - 当前正要执行的方法protected void assertValid(String methodName)
methodName - 当前正要执行的方法protected void assertAttributeNameForModification(String methodName, String attrName)
public void commit(boolean commitHeaders)
@Deprecated public javax.servlet.http.HttpSessionContext getSessionContext()
getSessionContext 在接口中 javax.servlet.http.HttpSession@Deprecated public Object getValue(String name)
getValue 在接口中 javax.servlet.http.HttpSession@Deprecated public String[] getValueNames()
getValueNames 在接口中 javax.servlet.http.HttpSession@Deprecated public void putValue(String name, Object value)
putValue 在接口中 javax.servlet.http.HttpSession@Deprecated public void removeValue(String name)
removeValue 在接口中 javax.servlet.http.HttpSessionCopyright © 2006-2013 开源组织. All Rights Reserved.