//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. oracle手工生成AWR报告方法记录

    AWR(Automatic Workload Repository)报告是我们进行日常数据库性能评定.问题SQL发现的重要手段.熟练掌握AWR报告,是做好开发.运维DBA工作的重要基本功. AWR报告 ...

  2. 【Unity Shader】新书封面 — Low Polygon风格的渲染

    写在前面 最近又开心又担心,因为我的书马上就要上市了,开心当然是因为等了这么久终于可以如愿了,担心是因为不少人对它的期待都很大,我第一次写书,能力也有限,不知道能不能让大家满意,让大家也都喜欢上它.不 ...

  3. SQL语句常见问题的总结(持续更新)

    语言问题 修改语言注册表\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432\ORACLE\KEY_DevSuitHome1中的NLS_LANG修改为AMERICAN_AMERIC ...

  4. For oracle databases, if the top showing the oracle database, then oracle process is using the top c

    Note 805586.1   Troubleshooting Session Administration (Doc ID 805586.1)Note 822527.1   How To Find ...

  5. ASCII 大文字生成器

    display text in large ASCII art fonts 显示大ASCII艺术字体 这种东西在源码声明或者软件初始化控制台打印时候很有用. 例如打开: http://www.oran ...

  6. XMPP(三)-安卓即时通讯客户端

    由于时间原因,所以更新比较慢 ,还请大家谅解,此次是对上篇文章中的安卓客户端初级版本进行的一次更新优化,在这次更新后,就有那么一点样子了,可以拿的出手了,呵呵,还在关注的同学也可以及时下载更新.此次主 ...

  7. 15 Action View 以及监听 的使用

    menu 代码 <menu xmlns:android="http://schemas.android.com/apk/res/android" > <!-- a ...

  8. Android简易实战教程--第十话《模仿腾讯手机助手小火箭发射详解》

    之前对系统自带的土司的源码做了简要分析,见博客:点击打开链接 这一篇给一个小案例,自定义土司,模拟腾讯卫士的小火箭发射.如果想要迅速看懂代码,建议先去看一下上篇介绍点击打开链接 首先,定义一个服务,在 ...

  9. Android ClassLoader详解

    我们知道不管是插件化还是组件化,都是基于系统的ClassLoader来设计的.只不过Android平台上虚拟机运行的是Dex字节码,一种对class文件优化的产物,传统Class文件是一个Java源码 ...

  10. 初探linux子系统集之timer子系统(三)

    因为现在的linux虽然还是可以使用低精度的timer,但是趋势是高精度hrtimer,所以上一篇试着翻译一下hrtimer的一些介绍,翻译的不是很好,看来英语还得好好学习啊,下面还是好好学习下lin ...