学习笔记---session
1.session 对象是由服务器创建,我们可以通过request的方法获得。HttpSessiongetSession()
Returns the current session associated with this request, or if the request does not have a session, creates one. HttpSessiongetSession(boolean create)
Returns the current HttpSession associated with this request or, if if there is no current session and create is true, returns a new session.
如果 .getSession(false).不会创建新的session
为了确保session能够被完全维持。servlet开发者必须在相应被提交之前调用该方法。
2.httpsession 对象一旦创建,就会非配一个唯一的ID,并且一cookie的形式写到客户端的缓存当中。
3.不能用invalidate()方法清空session
要用
voidremoveAttribute(java.lang.String name)
Removes the object bound with the specified name from this session.
页:
[1]