- 苏州马小云
-
叫某个人讲 真的不好讲
在java里面用的东西都是类 因为java是纯面向对象的语言
下面给你一些方法
Method Summary
Object getAttribute(String name)
Returns the object bound with the specified name in this session, or null if no object is bound under the name. 返回session中指定名称的绑定对象,如果没有对象被绑定,返回null。
Enumeration getAttributeNames()
Returns an Enumeration of String objects containing the names of all the objects bound to this session. 以String对象的枚举形式返回绑定给该session的所有对象名称。
long getCreationTime()
Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.返回session创建的时间,以1970年1月1日0点为起点。
String getId()
Returns a string containing the unique identifier assigned to this session. 返回一字符串,表示分配给session的唯一的标识符。
long getLastAccessedTime()
Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight January 1, 1970 GMT, and marked by the time the container received the request. 返回上一次该会话相关的客户端请求时间,表示为从GMT 1970年1月1日以来的毫秒值,标记为容器接收到请求的时间。
int getMaxInactiveInterval()
Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses. 以秒为单位返回最大间隔时间,在客户端访问之间servlet容器将保持会话开启。
ServletContext getServletContext()
Returns the ServletContext to which this session belongs. 返回session属于的ServletContext。
HttpSessionContext getSessionContext()
Deprecated. As of Version 2.1, this method is deprecated and has no replacement. It will be removed in a future version of the Java Servlet API. 从版本2.1以来,该方法不再支持,且没有替代方法。在Java Servlet API的以后版本中将被删除。
Object getValue(String name)
Deprecated. As of Version 2.2, this method is replaced by getAttribute(java.lang.String). 从版本2.2以来,该方法被getAttribute(java.lang.String)所替代。
String[] getValueNames()
Deprecated. As of Version 2.2, this method is replaced by getAttributeNames() 从版本2.2以来,该方法被getAttributeNames()所替代。
void invalidate()
Invalidates this session then unbinds any objects bound to it. 使session无效,解除所有对象的绑定。
boolean isNew()
Returns true if the client does not yet know about the session or if the client chooses not to join the session. 如果客户端不知道该会话或者没有选择加入该会话,返回true。
void putValue(String name, Object value)
Deprecated. As of Version 2.2, this method is replaced by setAttribute(java.lang.String, java.lang.Object) 从版本2.2以来,该方法被setAttribute(java.lang.String, java.lang.Object)所替代。
void removeAttribute(String name)
Removes the object bound with the specified name from this session. 从session中删除指定名称绑定的对象。
void removeValue(String name)
Deprecated. As of Version 2.2, this method is replaced by removeAttribute(java.lang.String) 从版本2.2以来,该方法被removeAttribute(java.lang.String)所替代。
void setAttribute(String name, Object value)
Binds an object to this session, using the name specified. 使用指定名称,向session绑定一个对象。
void setMaxInactiveInterval(int interval)
Specifies the time, in seconds, between client requests before the servlet container will invalidate this session. 以秒为单位指定servlet容器使会话失效之前客户端请求之间的间隔时间。
我建议你去找一个java帮助文档自己分析
- 阿啵呲嘚
-
如果你用的是TOMcat 服务器的话,在tomcat的帮助文件,会找到你所需要的session帮助方档的
- 小菜G
-
简单通俗的讲session就是象一个临时的容器
来存放这些临时的东西
从你登陆开始就保存在session里
当然你可以自己设置它的有效时间和页面
举个简单的例子
我们做一个购书的JSP网站
顾客买书的时候会挑选出一些书
但是在付钱之前还可以修改,所以不能存到数据库
就可以先保存在session里
等到确认了以后再放入数据库...
understand?