首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

学习札记-session

2012-11-25 
学习笔记---session1.session 对象是由服务器创建,我们可以通过request的方法获得。??HttpSessiongetSessio

学习笔记---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.

?

?

?

热点排行