六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 29|回复: 0

学习笔记---session

[复制链接]

升级  8.67%

70

主题

70

主题

70

主题

举人

Rank: 3Rank: 3

积分
226
 楼主| 发表于 2013-2-3 14:08:01 | 显示全部楼层 |阅读模式
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.
 
 
 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表