分享
 
 
 

javax.servlet.http.HttpSession翻译

王朝java/jsp·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

[/url] [url=file:///F:/资料/文字资料/j2ee-1.4_doc/apidocs/overview-summary.html]Overview

Package

Class

Tree

Deprecated

Index

Help

JavaTM 2 Platform

Ent. Ed. v1.4

PREV CLASS NEXT CLASS

FRAMES NO FRAMES All Classes

SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

javax.servlet.http

Interface HttpSessionpublic interface HttpSessionProvides a way to identify a user across more than one page request or visit to a Web site and to store information about that user. 提供了一种方式来标识跨越多个页面请求或访问网站的用户,存储用户的相关信息。

The servlet container uses this interface to create a session between an HTTP client and an HTTP server. The session persists for a specified time period, across more than one connection or page request from the user. A session usually corresponds to one user, who may visit a site many times. The server can maintain a session in many ways such as using cookies or rewriting URLs. servlet容器利用该接口创建位于HTTP客户端和HTTP服务器之间的会话。会话将保持指定的时间段,跨越多个连接或者来自用户的页面请求。会话通常相当于一个多次访问某个网址的用户。服务器可以使用多种方式来维护会话,比如使用cookies或重写URL。

This interface allows servlets to 该接口允许servlet

View and manipulate information about a session, such as the session identifier, creation time, and last accessed time 查看和操作session信息,比如session标识符,创建时间和上次访问时间 Bind objects to sessions, allowing user information to persist across multiple user connections 将对象与会话绑定,允许用户信息持久地跨越多个用户连接 When an application stores an object in or removes an object from a session, the session checks whether the object implements HttpSessionBindingListener. If it does, the servlet notifies the object that it has been bound to or unbound from the session. Notifications are sent after the binding methods complete. For session that are invalidated or expire, notifications are sent after the session has been invalidatd or expired. 当应用在会话中存储或者从会话中删除一个对象,会话将检查对象是否实现HttpSessionBindingListener。如果是,servlet通知会话中绑定或者解除绑定的对象。通知在绑定(解除绑定)完成后发送。对于无效或过期的会话,通知将在会话无效或过期后发送。

When container migrates a session between VMs in a distributed container setting, all session attributes implementing the HttpSessionActivationListener interface are notified. 当容器在分布式容器环境虚拟机中迁移会话,所有实现HttpSessionActivationListener接口的 会话属性将被通知。

A servlet should be able to handle cases in which the client does not choose to join a session, such as when cookies are intentionally turned off. Until the client joins the session, isNew returns true. If the client chooses not to join the session, getSession will return a different session on each request, and isNew will always return true. servlet应当能够处理客户端没有选择加入会话这种情况,比如cookies被故意关掉。除非客户端加入会话,isNew返回true。如果客户端选择不加入会话,

Session information is scoped only to the current web application (ServletContext), so information stored in one context will not be directly visible in another. 会话信息只在当前web应用中有效(ServletContext),因此存储在上下文中的信息对于另一个应用不能直接可见。

Version: $Version$ Author: Various See Also: HttpSessionBindingListener, HttpSessionContextMethod 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容器使会话失效之前客户端请求之间的间隔时间。

Method Detail

getCreationTimepublic long getCreationTime()

Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT. 返回session创建的时间,以1970年1月1日0点为起点。

Returns: a long specifying when this session was created, expressed in milliseconds since 1/1/1970 GMT long值,表示上一次该会话创建的时间,即从GMT 1970年1月1日以来的毫秒值 Throws: IllegalStateException - if this method is called on an invalidated session 如果方法调用是基于一个无效的会话则抛出getIdpublic String getId()

Returns a string containing the unique identifier assigned to this session. The identifier is assigned by the servlet container and is implementation dependent. 返回一字符串,表示分配给session的唯一的标识符。

Returns: a string specifying the identifier assigned to this session 表示分配给session的标识符字符串 Throws: IllegalStateException - if this method is called on an invalidated session 如果方法调用是基于一个无效的会话则抛出getLastAccessedTimepublic 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日以来的毫秒值,标记为容器接收到请求的时间。 Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time. 应用程序执行的动作,比如获取或设置会话的相关值,不影响访问时间。

Returns: a long representing the last time the client sent a request associated with this session, expressed in milliseconds since 1/1/1970 GMT long值,表示上一次该会话相关的客户端请求时间,即从GMT 1970年1月1日以来的毫秒值 Throws: IllegalStateException - if this method is called on an invalidated session 如果方法调用是基于一个无效的会话则抛出getServletContextpublic ServletContext getServletContext()

Returns the ServletContext to which this session belongs. 返回session属于的ServletContext。

Returns: The ServletContext object for the web application web应用的ServletContext对象 Since: 2.3 setMaxInactiveIntervalpublic void setMaxInactiveInterval(int interval)

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. 以秒为单位指定servlet容器使会话失效之前客户端请求之间的间隔时间。 负值表示会话永远不会超时。

Parameters: interval - An integer specifying the number of seconds 整数,表示秒数getMaxInactiveIntervalpublic int getMaxInactiveInterval()

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 setMaxInactiveInterval method. A negative time indicates the session should never timeout. 以秒为单位返回最大间隔时间,在客户端访问之间servlet容器将保持会话开启。 在间隔之后,servlet容器将使会话失效。最大间隔值可以通过setMaxInactiveInterval方法设置。

Returns: an integer specifying the number of seconds this session remains open between client requests 一个整数值,表示在客户端访问之间servlet容器保持会话开启的时间。 See Also: setMaxInactiveInterval(int)getSessionContextpublic 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的以后版本中将被删除。

getAttributepublic 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。

Parameters: name - a string specifying the name of the object 指定对象名称的字符串 Returns: the object with the specified name 指定名称的对象 Throws: IllegalStateException - if this method is called on an invalidated session 如果方法调用是基于一个无效的会话则抛出getValuepublic 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)所替代。

Parameters: name - a string specifying the name of the object 指定对象名称的字符串 Returns: the object with the specified name 指定名称的对象 Throws: IllegalStateException - if this method is called on an invalidated session 如果方法调用是基于一个无效的会话则抛出getAttributeNamespublic Enumeration getAttributeNames()

Returns an Enumeration of String objects containing the names of all the objects bound to this session. 以String对象的枚举形式返回绑定给该session的所有对象名称。

Returns: an Enumeration of String objects specifying the names of all the objects bound to this session String对象的枚举形式,表示绑定给该session的所有对象名称。 Throws: IllegalStateException - if this method is called on an invalidated session 如果方法调用是基于一个无效的会话则抛出getValueNamespublic String[] getValueNames()

Deprecated. As of Version 2.2, this method is replaced by getAttributeNames() 从版本2.2以来,该方法被getAttributeNames()所替代。

Returns: an array of String objects specifying the names of all the objects bound to this session 表示会话绑定的所有对象名称的String对象数组 Throws: IllegalStateException - if this method is called on an invalidated session 如果方法调用是基于一个无效的会话则抛出setAttributepublic void setAttribute(String name,

Object value)

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. 使用指定名称,向session绑定一个对象。如果一个相同名称的对象已绑定给session,原对象被替代。 After this method executes, and if the new object implements HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueBound. The container then notifies any HttpSessionAttributeListeners in the web application. 在方法执行之后,如果对象实现了HttpSessionBindingListener,那么容器调用HttpSessionBindingListener.valueBound。 容器通知web应用中的所有HttpSessionAttributeListener。

If an object was already bound to this session of this name that implements HttpSessionBindingListener, its HttpSessionBindingListener.valueUnbound method is called. 如果已用该名称绑定给session的原对象实现HttpSessionBindingListener,那么调用HttpSessionBindingListener.valueUnbound方法。

If the value passed in is null, this has the same effect as calling removeAttribute(). 如果值传递为null,那么效果与调用removeAttribute()相同。

Parameters: name - the name to which the object is bound; cannot be null 对象要绑定的名称,不能为null value - the object to be bound 要绑定的对象 Throws: IllegalStateException - if this method is called on an invalidated session 如果方法调用是基于一个无效的会话则抛出putValuepublic 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)所替代。

Parameters: name - the name to which the object is bound; cannot be null 对象要绑定的名称,不能为null value - the object to be bound; cannot be null 要绑定的对象,不能为null Throws: IllegalStateException - if this method is called on an invalidated session 如果方法调用是基于一个无效的会话则抛出removeAttributepublic void removeAttribute(String name)

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. 从session中删除指定名称绑定的对象。如果session中不含指定名称的绑定对象,那么方法不做任何事。 After this method executes, and if the object implements HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueUnbound. The container then notifies any HttpSessionAttributeListeners in the web application. 在方法执行之后,如果对象实现了HttpSessionBindingListener,那么容器调用HttpSessionBindingListener.valueUnbound。 容器通知web应用中的所有HttpSessionAttributeListener。

Parameters: name - the name of the object to remove from this session 要从session中删除的对象名称 Throws: IllegalStateException - if this method is called on an invalidated session 如果方法调用是基于一个无效的会话则抛出removeValuepublic 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)所替代。

Parameters: name - the name of the object to remove from this session 要从session中删除的对象名称 Throws: IllegalStateException - if this method is called on an invalidated session 如果方法调用是基于一个无效的会话则抛出invalidatepublic void invalidate()

Invalidates this session then unbinds any objects bound to it. 使session无效,解除所有对象的绑定。

Throws: IllegalStateException - if this method is called on an already invalidated session 如果方法调用是基于一个已经无效的会话则抛出isNewpublic boolean isNew()

Returns true 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. 如果客户端不知道该会话或者没有选择加入该会话,返回true。比如,如果服务器使用基于cookie的会话, 客户端不能禁用cookies,那么会话对于每一个请求将是新的。

Returns: true if the server has created a session, but the client has not yet joined 如果服务器创建了一个会话,但是客户端还没有加入,返回true Throws: IllegalStateException - if this method is called on an already invalidated session 如果方法调用是基于一个已经无效的会话则抛出[/url][url=file:///F:/资料/文字资料/j2ee-1.4_doc/apidocs/overview-summary.html]Overview

Package

Class

Tree

Deprecated

Index

Help

JavaTM 2 Platform

Ent. Ed. v1.4

PREV CLASS NEXT CLASS

FRAMES NO FRAMES All Classes

SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature Copyright 2003 Sun Microsystems, Inc. All rights reserved.

Parameters: name - the name to which the object is bound; cannot be null 对象要绑定的名称,不能为null value - the object to be bound 要绑定的对象 Throws: IllegalStateException - if this method is called on an invalidated session 如果方法调用是基于一个无效的会话则抛出putValuepublic 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)所替代。

Parameters: name - the name to which the object is bound; cannot be null 对象要绑定的名称,不能为null value - the object to be bound; cannot be null 要绑定的对象,不能为null Throws: IllegalStateException - if this method is called on an invalidated session 如果方法调用是基于一个无效的会话则抛出removeAttributepublic void removeAttribute(String name)

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. 从session中删除指定名称绑定的对象。如果session中不含指定名称的绑定对象,那么方法不做任何事。 After this method executes, and if the object implements HttpSessionBindingListener, the container calls HttpSessionBindingListener.valueUnbound. The container then notifies any HttpSessionAttributeListeners in the web application. 在方法执行之后,如果对象实现了HttpSessionBindingListener,那么容器调用HttpSessionBindingListener.valueUnbound。 容器通知web应用中的所有HttpSessionAttributeListener。

Parameters: name - the name of the object to remove from this session 要从session中删除的对象名称 Throws: IllegalStateException - if this method is called on an invalidated session 如果方法调用是基于一个无效的会话则抛出removeValuepublic 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)所替代。

Parameters: name - the name of the object to remove from this session 要从session中删除的对象名称 Throws: IllegalStateException - if this method is called on an invalidated session 如果方法调用是基于一个无效的会话则抛出invalidatepublic void invalidate()

Invalidates this session then unbinds any objects bound to it. 使session无效,解除所有对象的绑定。

Throws: IllegalStateException - if this method is called on an already invalidated session 如果方法调用是基于一个已经无效的会话则抛出isNewpublic boolean isNew()

Returns true 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. 如果客户端不知道该会话或者没有选择加入该会话,返回true。比如,如果服务器使用基于cookie的会话, 客户端不能禁用cookies,那么会话对于每一个请求将是新的。

Returns: true if the server has created a session, but the client has not yet joined 如果服务器创建了一个会话,但是客户端还没有加入,返回true Throws: IllegalStateException - if this method is called on an already invalidated session 如果方法调用是基于一个已经无效的会话则抛出[/url][url=file:///F:/资料/文字资料/j2ee-1.4_doc/apidocs/overview-summary.html]Overview

Package

Class

Tree

Deprecated

Index

Help

JavaTM 2 Platform

Ent. Ed. v1.4

PREV CLASS NEXT CLASS

FRAMES NO FRAMES All Classes

SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature Copyright 2003 Sun Microsystems, Inc. All rights reserved.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有