Java-HttpSession
//session给用户一种标志,让用户可以在不同页面以及网站中都有一个特殊的标记
public interface HttpSession {
/**
* Returns the time when this session was created, measured
* in milliseconds since midnight January 1, 1970 GMT.
* @return a <code>long</code> specifying
* when this session was created, expressed in milliseconds since 1/1/1970 GMT
* @exception IllegalStateException if this method is called on an
* invalidated session
*/
//session创建时间
public long getCreationTime();
/**
* Returns a string containing the unique identifier assigned
* to this session. The identifier is assigned
* by the servlet container and is implementation dependent.
* @return a string specifying the identifier
* assigned to this session
* @exception IllegalStateException if this method is called on an
* invalidated session
*/
//session id
public String getId();
/**
* 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.
* <p>Actions that your application takes, such as getting or setting
* a value associated with the session, do not affect the access time.
* @return a <code>long</code>
* representing the last time
* the client sent a request associated
* with this session, expressed in
* milliseconds since 1/1/1970 GMT
* @exception IllegalStateException if this method is called on an
* invalidated session
*/
//最近一次客户端发送与这个session相关联的请求的时间
public long getLastAccessedTime();
/**
* Returns the ServletContext to which this session belongs.
* @return The ServletContext object for the web application
* @since 2.3
*/
//session所属于的ServletContext
public ServletContext getServletContext();
/**
* Specifies the time, in seconds, between client requests before the
* servlet container will invalidate this session. A negative time
* indicates the session should never timeout.
* @param interval An integer specifying the number of seconds
*/
//session失效时间
public void setMaxInactiveInterval(int interval);
/**
* Returns the maximum time interval, in seconds, that
* the servlet container will keep this session open between
* client accesses. After this interval, the servlet container
* will invalidate the session. The maximum time interval can be set
* with the <code>setMaxInactiveInterval</code> method.
* A negative time indicates the session should never timeout.
* @return an integer specifying the number of
* seconds this session remains open
* between client requests
* @see #setMaxInactiveInterval
*/
//获得失效时间
public int getMaxInactiveInterval();
/**
* @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.
*/
public HttpSessionContext getSessionContext();
/**
* Returns the object bound with the specified name in this session, or
* <code>null</code> if no object is bound under the name.
* @param name a string specifying the name of the object
* @return the object with the specified name
* @exception IllegalStateException if this method is called on an
* invalidated session
*/
//session中name的对象
public Object getAttribute(String name);
/**
* @deprecated As of Version 2.2, this method is
* replaced by {@link #getAttribute}.
* @param name a string specifying the name of the object
* @return the object with the specified name
* @exception IllegalStateException if this method is called on an
* invalidated session
*/
public Object getValue(String name);
/**
* Returns an <code>Enumeration</code> of <code>String</code> objects
* containing the names of all the objects bound to this session.
* @return an <code>Enumeration</code> of
* <code>String</code> objects specifying the
* names of all the objects bound to
* this session
* @exception IllegalStateException if this method is called on an
* invalidated session
*/
//获得所有属性的枚举
public Enumeration getAttributeNames();
/**
* @deprecated As of Version 2.2, this method is
* replaced by {@link #getAttributeNames}
* @return an array of <code>String</code>
* objects specifying the
* names of all the objects bound to
* this session
* @exception IllegalStateException if this method is called on an
* invalidated session
*/
public String[] getValueNames();
/**
* Binds an object to this session, using the name specified.
* If an object of the same name is already bound to the session,
* the object is replaced.
* <p>After this method executes, and if the new object
* implements <code>HttpSessionBindingListener</code>,
* the container calls
* <code>HttpSessionBindingListener.valueBound</code>. The container then
* notifies any <code>HttpSessionAttributeListener</code>s in the web
* application.
* <p>If an object was already bound to this session of this name
* that implements <code>HttpSessionBindingListener</code>, its
* <code>HttpSessionBindingListener.valueUnbound</code> method is called.
* <p>If the value passed in is null, this has the same effect as calling
* <code>removeAttribute()<code>.
* @param name the name to which the object is bound;
* cannot be null
* @param value the object to be bound
* @exception IllegalStateException if this method is called on an
* invalidated session
*/
//设置属性
public void setAttribute(String name, Object value);
/**
*
* @deprecated As of Version 2.2, this method is
* replaced by {@link #setAttribute}
*
* @param name the name to which the object is bound;
* cannot be null
*
* @param value the object to be bound; cannot be null
*
* @exception IllegalStateException if this method is called on an
* invalidated session
*
*/
public void putValue(String name, Object value);
/**
* Removes the object bound with the specified name from
* this session. If the session does not have an object
* bound with the specified name, this method does nothing.
* <p>After this method executes, and if the object
* implements <code>HttpSessionBindingListener</code>,
* the container calls
* <code>HttpSessionBindingListener.valueUnbound</code>. The container
* then notifies any <code>HttpSessionAttributeListener</code>s in the web
* application.
* @param name the name of the object to
* remove from this session
* @exception IllegalStateException if this method is called on an
* invalidated session
*/
//删除属性
public void removeAttribute(String name);
/**
* @deprecated As of Version 2.2, this method is
* replaced by {@link #removeAttribute}
* @param name the name of the object to
* remove from this session
* @exception IllegalStateException if this method is called on an
* invalidated session
*/
public void removeValue(String name);
/**
* Invalidates this session then unbinds any objects bound
* to it.
* @exception IllegalStateException if this method is called on an
* already invalidated session
*/
//session无效
public void invalidate();
/**
* Returns <code>true</code> if the client does not yet know about the
* session or if the client chooses not to join the session. For
* example, if the server used only cookie-based sessions, and
* the client had disabled the use of cookies, then a session would
* be new on each request.
* @return <code>true</code> if the
* server has created a session,
* but the client has not yet joined
* @exception IllegalStateException if this method is called on an
* already invalidated session
*/
//
public boolean isNew();
}
Java-HttpSession的更多相关文章
- java httpSession 设置超时时间
1.设置过期时间方式一:在tomcat/conf/web.xml下加入一下内容 <session-config> <session-timeout>90</session ...
- 02 Filter过滤器
Filter 一.Filter过滤器 Filter过滤器它是JavaWeb的三大组件之一.三大组件分别是:Servlet程序.Listener监听器.Filter过滤器 Filter过滤器是JavaE ...
- Spark案例分析
一.需求:计算网页访问量前三名 import org.apache.spark.rdd.RDD import org.apache.spark.{SparkConf, SparkContext} /* ...
- java使用websocket,并且获取HttpSession,源码分析
转载请在页首注明作者与出处 http://www.cnblogs.com/zhuxiaojie/p/6238826.html 一:本文使用范围 此文不仅仅局限于spring boot,普通的sprin ...
- [原创]java WEB学习笔记47:Servlet 监听器简介, ServletContext(Application 对象), HttpSession (Session 对象), HttpServletRequest (request 对象) 监听器,利用listener理解 三个对象的生命周期
本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...
- Java中Httpsession是如何实现的?
HTTP协议(http://www.w3.org/Protocols/)是“一次性单向”协议. 服务端不能主动连接客户端,只能被动等待并答复客户端请求.客户端连接服务端,发出一个HTTP Reques ...
- Java WebSocket HttpSession与WebSocket Session的关联
当HttpSession中止(通过显示地失效或超时)时,Web容器会把HttpSession属性从HttpSession中清除. javax.servlet.http.HttpSessionBindi ...
- java学习笔记—使用HttpSession实现QQ的访问记录(31)
1. 编写QQ空间数据类(QQS.java) public class QQS { private static LinkedHashMap<Integer, String> qqs = ...
- java WEB学习笔记32:HttpSession 接口常用方法 及 HttpServletRequest接口中的Session方法 Demo
本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...
- java使用Websocket获取HttpSession出现的问题与解决
websocket的写法就不多说了,主要记一记其中出现的问题 1.获取不到httpSession 解决办法:先重写握手方法,将httpsession放入ServerEndpointConfig.get ...
随机推荐
- Hadoop MapReduce工作原理
在学习Hadoop,慢慢的从使用到原理,逐层的深入吧 第一部分:MapReduce工作原理 MapReduce 角色 •Client :作业提交发起者. •JobTracker: 初始化作业,分配 ...
- 剑指Offer——分治算法
剑指Offer--分治算法 基本概念 在计算机科学中,分治法是一种很重要的算法.字面上的解释是"分而治之",就是把一个复杂的问题分成两个或更多的相同或相似的子问题,再把子问题分成更 ...
- 02_c3p0之c3p0-config.xml配置案例,操作c3p0的jdbcUtil工具类的编写
c3p0也是一个开源jdbc连接池,我们熟悉的Hibernate和Spring框架使用的都是该数据源. 这里获得数据源使用的方法是:ComboPooledDataSource 它提供的构造方法有 ...
- 一个iOS6系统bug+一个iOS7系统bug
先看实际工作中遇到的两个bug:(1)iPhone Qzone有一个导航栏背景随着页面滑动而渐变的体验,当页面滑动到一定距离时,会改变导航栏上title文本的颜色,但是有一个莫名其妙的bug,如下:
- 最简单的基于libVLC的例子:最简单的基于libVLC的视频播放器(图形界面版)
===================================================== 最简单的基于libVLC的例子文章列表: 最简单的基于libVLC的例子:最简单的基于lib ...
- 深入剖析Tomcat类加载机制
1JVM类加载机制 JVM的ClassLoader通过Parent属性定义父子关系,可以形成树状结构.其中引导类.扩展类.系统类三个加载器是JVM内置的. 它们的作用分别是: 1)引导类加载器:使用n ...
- debian 安装jdk
JDK下载http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6- ...
- 03一些View总结
第三天 一 TextView 父类 : View >概念:文本控件 :文本内容的显示 默认配置不可编辑 子类EditText可以编辑 >属性: ...
- (七十三)iOS本地推送通知的实现
iOS的推送通知分为本地推送和网络推送两种,如果App处于挂起状态,是可以发送本地通知的,如果已经被杀掉,则只有定时通知可以被执行,而类似于QQ的那种网络消息推送就无法实现了,因为App的网络模块在被 ...
- 深入浅出Java Dom4j读取XML
在以前自己使用的xml较少,只是了解其很强大,现在可算是在DRP中,真正的开始使用它了,以前只是简单的理解xml,xml即可扩展标记语言,简单的使用,具体是什么?怎么用?还是一直让自己期待的. 首先来 ...