//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的更多相关文章

  1. java httpSession 设置超时时间

    1.设置过期时间方式一:在tomcat/conf/web.xml下加入一下内容 <session-config> <session-timeout>90</session ...

  2. 02 Filter过滤器

    Filter 一.Filter过滤器 Filter过滤器它是JavaWeb的三大组件之一.三大组件分别是:Servlet程序.Listener监听器.Filter过滤器 Filter过滤器是JavaE ...

  3. Spark案例分析

    一.需求:计算网页访问量前三名 import org.apache.spark.rdd.RDD import org.apache.spark.{SparkConf, SparkContext} /* ...

  4. java使用websocket,并且获取HttpSession,源码分析

    转载请在页首注明作者与出处 http://www.cnblogs.com/zhuxiaojie/p/6238826.html 一:本文使用范围 此文不仅仅局限于spring boot,普通的sprin ...

  5. [原创]java WEB学习笔记47:Servlet 监听器简介, ServletContext(Application 对象), HttpSession (Session 对象), HttpServletRequest (request 对象) 监听器,利用listener理解 三个对象的生命周期

    本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...

  6. Java中Httpsession是如何实现的?

    HTTP协议(http://www.w3.org/Protocols/)是“一次性单向”协议. 服务端不能主动连接客户端,只能被动等待并答复客户端请求.客户端连接服务端,发出一个HTTP Reques ...

  7. Java WebSocket HttpSession与WebSocket Session的关联

    当HttpSession中止(通过显示地失效或超时)时,Web容器会把HttpSession属性从HttpSession中清除. javax.servlet.http.HttpSessionBindi ...

  8. java学习笔记—使用HttpSession实现QQ的访问记录(31)

    1. 编写QQ空间数据类(QQS.java) public class QQS { private static LinkedHashMap<Integer, String> qqs = ...

  9. java WEB学习笔记32:HttpSession 接口常用方法 及 HttpServletRequest接口中的Session方法 Demo

    本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...

  10. java使用Websocket获取HttpSession出现的问题与解决

    websocket的写法就不多说了,主要记一记其中出现的问题 1.获取不到httpSession 解决办法:先重写握手方法,将httpsession放入ServerEndpointConfig.get ...

随机推荐

  1. 2016年年终CSDN博客总结

    2015年12月1日,结束了4个月的尚观嵌入式培训生涯,经过了几轮重重面试,最终来到了伟易达集团.经过了长达3个月的试用期,正式成为了伟易达集团的助理工程师. 回顾一年来的学习,工作,生活.各种酸甜苦 ...

  2. 阻塞IO服务器模型之多线程服务器模型

    针对单线程服务器模型的特点,我们可以对其进行改进,使之能对多个客户端同时进行响应.最简单的改进即是使用多线程(或多进程)服务器模型,在应用层级别,我们一般采用多线程模式.多线程能让多个客户端同时请求, ...

  3. java虚拟机 jvm 方法区实战

    和java堆一样,方法区是一块所有线程共享的内存区域,用于保存系统的类信息,类的信息有哪些呢.字段.方法.常量池.方法区也有一块内存区域所以方法区的内存大小,决定了系统可以包含多少个类,如果系统类太多 ...

  4. 在Linux环境下实现一个非常好的bash脚本框架

    为了方便我日常工作中的编译环境,免去我敲命令行所浪费的时间,我个人写了一个非常有用而又简单的脚本框架,该框架即可以完成的工程源码编译,也可以清除,拷贝等等操作,具体需要开发者自己来实现细节,我的框架思 ...

  5. DBoW2应用

    图像对应的bag-of-words向量\(v_t\) 假设词典总共有\(W\)个单词,那么每一幅图像能够用一个\(W\)维的向量表示 \((t_1, t_2, t_3, ..., t_W)\)其中 \ ...

  6. iOS下JS与OC互相调用(二)--WKWebView 拦截URL

    在上篇文章中讲述了使用UIWebView拦截URL的方式来处理JS与OC交互. 由于UIWebView比较耗内存,性能上不太好,而苹果在iOS 8中推出了WKWebView. 同样的用WKWebVie ...

  7. Cocos2D在Xcode7和iOS 9.2上IMP调用出错

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 原来的代码一直在Xcode6.4上和iOS 8.4上运行,没有 ...

  8. Android传感器概述-android学习之旅(七)

    传感器概述 传感器是第二代智能手机的重要标志之一.现在许多的手机和平板都内置了传感器(tv除外).android的SDK支持许多的传感器有十几种,但是手机只是支持一部分.例如方向传感器(电子罗盘)和重 ...

  9. 【一天一道LeetCode】#225. Implement Stack using Queues

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Impleme ...

  10. [python] Start a http server

    If you want to start a simple httpserver on your windows, you may choose python.simpleHTTPServer mod ...