?? httpsession.html
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Mon Sep 29 15:11:55 PDT 2003 --><TITLE>: Interface HttpSession</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT ID="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT ID="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT ID="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT ID="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT ID="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT ID="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../javax/servlet/http/HttpServletResponse.html"><B>PREV CLASS</B></A> <A HREF="../../../javax/servlet/http/HttpSessionActivationListener.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="HttpSession.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.servlet.http</FONT><BR>Interface HttpSession</H2><HR><DL><DT>public interface <B>HttpSession</B></DL><P>Provides 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. <p>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. <p>This interface allows servlets to <ul> <li>View and manipulate information about a session, such as the session identifier, creation time, and last accessed time <li>Bind objects to sessions, allowing user information to persist across multiple user connections </ul> <p>When an application stores an object in or removes an object from a session, the session checks whether the object implements <A HREF="../../../javax/servlet/http/HttpSessionBindingListener.html"><CODE>HttpSessionBindingListener</CODE></A>. 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 invalidated or expired. <p> When container migrates a session between VMs in a distributed container setting, all session attributes implementing the <A HREF="../../../javax/servlet/http/HttpSessionActivationListener.html"><CODE>HttpSessionActivationListener</CODE></A> interface are notified. <p>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, <code>isNew</code> returns <code>true</code>. If the client chooses not to join the session, <code>getSession</code> will return a different session on each request, and <code>isNew</code> will always return <code>true</code>. <p>Session information is scoped only to the current web application (<code>ServletContext</code>), so information stored in one context will not be directly visible in another.<P><DL><DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/HttpSessionBindingListener.html"><CODE>HttpSessionBindingListener</CODE></A>, <A HREF="../../../javax/servlet/http/HttpSessionContext.html"><CODE>HttpSessionContext</CODE></A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.lang.Object</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#getAttribute(java.lang.String)">getAttribute</A></B>(java.lang.String name)</CODE><BR> Returns the object bound with the specified name in this session, or <code>null</code> if no object is bound under the name.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.util.Enumeration</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#getAttributeNames()">getAttributeNames</A></B>()</CODE><BR> Returns an <code>Enumeration</code> of <code>String</code> objects containing the names of all the objects bound to this session.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> long</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#getCreationTime()">getCreationTime</A></B>()</CODE><BR> Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.lang.String</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#getId()">getId</A></B>()</CODE><BR> Returns a string containing the unique identifier assigned to this session.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> long</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#getLastAccessedTime()">getLastAccessedTime</A></B>()</CODE><BR> 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.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#getMaxInactiveInterval()">getMaxInactiveInterval</A></B>()</CODE><BR> Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../javax/servlet/ServletContext.html">ServletContext</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#getServletContext()">getServletContext</A></B>()</CODE><BR> Returns the ServletContext to which this session belongs.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../../javax/servlet/http/HttpSessionContext.html">HttpSessionContext</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#getSessionContext()">getSessionContext</A></B>()</CODE><BR> <B>Deprecated.</B> <I>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.</I></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.lang.Object</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#getValue(java.lang.String)">getValue</A></B>(java.lang.String name)</CODE><BR> <B>Deprecated.</B> <I>As of Version 2.2, this method is replaced by <A HREF="../../../javax/servlet/http/HttpSession.html#getAttribute(java.lang.String)"><CODE>getAttribute(java.lang.String)</CODE></A>.</I></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> java.lang.String[]</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#getValueNames()">getValueNames</A></B>()</CODE><BR> <B>Deprecated.</B> <I>As of Version 2.2, this method is replaced by <A HREF="../../../javax/servlet/http/HttpSession.html#getAttributeNames()"><CODE>getAttributeNames()</CODE></A></I></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#invalidate()">invalidate</A></B>()</CODE><BR> Invalidates this session then unbinds any objects bound to it.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#isNew()">isNew</A></B>()</CODE><BR> Returns <code>true</code> if the client does not yet know about the session or if the client chooses not to join the session.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#putValue(java.lang.String, java.lang.Object)">putValue</A></B>(java.lang.String name, java.lang.Object value)</CODE><BR> <B>Deprecated.</B> <I>As of Version 2.2, this method is replaced by <A HREF="../../../javax/servlet/http/HttpSession.html#setAttribute(java.lang.String, java.lang.Object)"><CODE>setAttribute(java.lang.String, java.lang.Object)</CODE></A></I></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#removeAttribute(java.lang.String)">removeAttribute</A></B>(java.lang.String name)</CODE><BR> Removes the object bound with the specified name from this session.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#removeValue(java.lang.String)">removeValue</A></B>(java.lang.String name)</CODE><BR> <B>Deprecated.</B> <I>As of Version 2.2, this method is replaced by <A HREF="../../../javax/servlet/http/HttpSession.html#removeAttribute(java.lang.String)"><CODE>removeAttribute(java.lang.String)</CODE></A></I></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#setAttribute(java.lang.String, java.lang.Object)">setAttribute</A></B>(java.lang.String name, java.lang.Object value)</CODE><BR> Binds an object to this session, using the name specified.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/servlet/http/HttpSession.html#setMaxInactiveInterval(int)">setMaxInactiveInterval</A></B>(int interval)</CODE><BR> Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.</TD></TR></TABLE> <P><!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="getCreationTime()"><!-- --></A><H3>getCreationTime</H3><PRE>public long <B>getCreationTime</B>()</PRE><DL><DD>Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.<DD><DL><DT><B>Returns:</B><DD>a <code>long</code> specifying when this session was created, expressed in milliseconds since 1/1/1970 GMT<DT><B>Throws:</B><DD>IllegalStateException - if this method is called on an invalidated session</DL></DD>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -