httpservletrequest.html

来自「SUN公司官方J2EE中文帮助文档 应该不错 有兴趣的下来看看 html格式的」· HTML 代码 · 共 1,051 行 · 第 1/3 页

HTML
1,051
字号
			of the request</DL>
</DD>
</DL>
<HR>

<A NAME="getQueryString()"><!-- --></A><H3>
getQueryString</H3>
<PRE>
public java.lang.String <B>getQueryString</B>()</PRE>
<DL>
<DD>Returns the query string that is contained in the request
 URL after the path. This method returns <code>null</code>
 if the URL does not have a query string. Same as the value
 of the CGI variable QUERY_STRING.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>a <code>String</code> containing the query
			string or <code>null</code> if the URL 
			contains no query string. The value is not
			decoded by the container.</DL>
</DD>
</DL>
<HR>

<A NAME="getRemoteUser()"><!-- --></A><H3>
getRemoteUser</H3>
<PRE>
public java.lang.String <B>getRemoteUser</B>()</PRE>
<DL>
<DD>Returns the login of the user making this request, if the
 user has been authenticated, or <code>null</code> if the user 
 has not been authenticated.
 Whether the user name is sent with each subsequent request
 depends on the browser and type of authentication. Same as the 
 value of the CGI variable REMOTE_USER.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>a <code>String</code> specifying the login
			of the user making this request, or <code>null</code
			if the user login is not known</DL>
</DD>
</DL>
<HR>

<A NAME="isUserInRole(java.lang.String)"><!-- --></A><H3>
isUserInRole</H3>
<PRE>
public boolean <B>isUserInRole</B>(java.lang.String&nbsp;role)</PRE>
<DL>
<DD>Returns a boolean indicating whether the authenticated user is included
 in the specified logical "role".  Roles and role membership can be
 defined using deployment descriptors.  If the user has not been
 authenticated, the method returns <code>false</code>.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>role</CODE> - a <code>String</code> specifying the name
				of the role<DT><B>Returns:</B><DD>a <code>boolean</code> indicating whether
			the user making this request belongs to a given role;
			<code>false</code> if the user has not been 
			authenticated</DL>
</DD>
</DL>
<HR>

<A NAME="getUserPrincipal()"><!-- --></A><H3>
getUserPrincipal</H3>
<PRE>
public java.security.Principal <B>getUserPrincipal</B>()</PRE>
<DL>
<DD>Returns a <code>java.security.Principal</code> object containing
 the name of the current authenticated user. If the user has not been
 authenticated, the method returns <code>null</code>.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>a <code>java.security.Principal</code> containing
			the name of the user making this request;
			<code>null</code> if the user has not been 
			authenticated</DL>
</DD>
</DL>
<HR>

<A NAME="getRequestedSessionId()"><!-- --></A><H3>
getRequestedSessionId</H3>
<PRE>
public java.lang.String <B>getRequestedSessionId</B>()</PRE>
<DL>
<DD>Returns the session ID specified by the client. This may
 not be the same as the ID of the actual session in use.
 For example, if the request specified an old (expired)
 session ID and the server has started a new session, this
 method gets a new session with a new ID. If the request
 did not specify a session ID, this method returns
 <code>null</code>.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>a <code>String</code> specifying the session
			ID, or <code>null</code> if the request did
			not specify a session ID<DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/HttpServletRequest.html#isRequestedSessionIdValid()"><CODE>isRequestedSessionIdValid()</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getRequestURI()"><!-- --></A><H3>
getRequestURI</H3>
<PRE>
public java.lang.String <B>getRequestURI</B>()</PRE>
<DL>
<DD>Returns the part of this request's URL from the protocol
 name up to the query string in the first line of the HTTP request.
 The web container does not decode this String.
 For example:

 

 <table>
 <tr align=left><th>First line of HTTP request      </th>
 <th>     Returned Value</th>
 <tr><td>POST /some/path.html HTTP/1.1<td><td>/some/path.html
 <tr><td>GET http://foo.bar/a.html HTTP/1.0
 <td><td>/a.html
 <tr><td>HEAD /xyz?a=b HTTP/1.1<td><td>/xyz
 </table>
      
 <p>To reconstruct an URL with a scheme and host, use
 <A HREF="../../../javax/servlet/http/HttpUtils.html#getRequestURL(javax.servlet.http.HttpServletRequest)"><CODE>HttpUtils.getRequestURL(javax.servlet.http.HttpServletRequest)</CODE></A>.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>a <code>String</code> containing
			the part of the URL from the 
			protocol name up to the query string<DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/HttpUtils.html#getRequestURL(javax.servlet.http.HttpServletRequest)"><CODE>HttpUtils.getRequestURL(javax.servlet.http.HttpServletRequest)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getRequestURL()"><!-- --></A><H3>
getRequestURL</H3>
<PRE>
public java.lang.StringBuffer <B>getRequestURL</B>()</PRE>
<DL>
<DD>Reconstructs the URL the client used to make the request.
 The returned URL contains a protocol, server name, port
 number, and server path, but it does not include query
 string parameters.
 
 <p>Because this method returns a <code>StringBuffer</code>,
 not a string, you can modify the URL easily, for example,
 to append query parameters.

 <p>This method is useful for creating redirect messages
 and for reporting errors.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>a <code>StringBuffer</code> object containing
			the reconstructed URL</DL>
</DD>
</DL>
<HR>

<A NAME="getServletPath()"><!-- --></A><H3>
getServletPath</H3>
<PRE>
public java.lang.String <B>getServletPath</B>()</PRE>
<DL>
<DD>Returns the part of this request's URL that calls
 the servlet. This includes either the servlet name or
 a path to the servlet, but does not include any extra
 path information or a query string. Same as the value 
 of the CGI variable SCRIPT_NAME.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>a <code>String</code> containing
			the name or path of the servlet being
			called, as specified in the request URL,
			decoded.</DL>
</DD>
</DL>
<HR>

<A NAME="getSession(boolean)"><!-- --></A><H3>
getSession</H3>
<PRE>
public <A HREF="../../../javax/servlet/http/HttpSession.html">HttpSession</A> <B>getSession</B>(boolean&nbsp;create)</PRE>
<DL>
<DD>Returns the current <code>HttpSession</code>
 associated with this request or, if if there is no
 current session and <code>create</code> is true, returns 
 a new session.

 <p>If <code>create</code> is <code>false</code>
 and the request has no valid <code>HttpSession</code>,
 this method returns <code>null</code>.

 <p>To make sure the session is properly maintained,
 you must call this method before 
 the response is committed. If the container is using cookies
 to maintain session integrity and is asked to create a new session
 when the response is committed, an IllegalStateException is thrown.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE><code>true</code></CODE> - to create
			a new session for this request if necessary; 
			<code>false</code> to return <code>null</code>
			if there's no current session<DT><B>Returns:</B><DD>the <code>HttpSession</code> associated 
			with this request or <code>null</code> if
 			<code>create</code> is <code>false</code>
			and the request has no valid session<DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/HttpServletRequest.html#getSession()"><CODE>getSession()</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getSession()"><!-- --></A><H3>
getSession</H3>
<PRE>
public <A HREF="../../../javax/servlet/http/HttpSession.html">HttpSession</A> <B>getSession</B>()</PRE>
<DL>
<DD>Returns the current session associated with this request,
 or if the request does not have a session, creates one.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>the <code>HttpSession</code> associated
			with this request<DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/HttpServletRequest.html#getSession(boolean)"><CODE>getSession(boolean)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="isRequestedSessionIdValid()"><!-- --></A><H3>
isRequestedSessionIdValid</H3>
<PRE>
public boolean <B>isRequestedSessionIdValid</B>()</PRE>
<DL>
<DD>Checks whether the requested session ID is still valid.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD><code>true</code> if this
				request has an id for a valid session
				in the current session context;
				<code>false</code> otherwise<DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/HttpServletRequest.html#getRequestedSessionId()"><CODE>getRequestedSessionId()</CODE></A>, 
<A HREF="../../../javax/servlet/http/HttpServletRequest.html#getSession(boolean)"><CODE>getSession(boolean)</CODE></A>, 
<A HREF="../../../javax/servlet/http/HttpSessionContext.html"><CODE>HttpSessionContext</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="isRequestedSessionIdFromCookie()"><!-- --></A><H3>
isRequestedSessionIdFromCookie</H3>
<PRE>
public boolean <B>isRequestedSessionIdFromCookie</B>()</PRE>
<DL>
<DD>Checks whether the requested session ID came in as a cookie.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD><code>true</code> if the session ID
				came in as a
				cookie; otherwise, <code>false</code><DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/HttpServletRequest.html#getSession(boolean)"><CODE>getSession(boolean)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="isRequestedSessionIdFromURL()"><!-- --></A><H3>
isRequestedSessionIdFromURL</H3>
<PRE>
public boolean <B>isRequestedSessionIdFromURL</B>()</PRE>
<DL>
<DD>Checks whether the requested session ID came in as part of the 
 request URL.<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD><code>true</code> if the session ID
				came in as part of a URL; otherwise,
				<code>false</code><DT><B>See Also: </B><DD><A HREF="../../../javax/servlet/http/HttpServletRequest.html#getSession(boolean)"><CODE>getSession(boolean)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="isRequestedSessionIdFromUrl()"><!-- --></A><H3>
isRequestedSessionIdFromUrl</H3>
<PRE>
public boolean <B>isRequestedSessionIdFromUrl</B>()</PRE>
<DL>
<DD><B>Deprecated.</B>&nbsp;<I>As of Version 2.1 of the Java Servlet
				API, use <A HREF="../../../javax/servlet/http/HttpServletRequest.html#isRequestedSessionIdFromURL()"><CODE>isRequestedSessionIdFromURL()</CODE></A>
				instead.</I>
<P>
<DD><DL>
</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>

<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_bottom"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_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 CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;PREV CLASS&nbsp;
&nbsp;<A HREF="../../../javax/servlet/http/HttpServletResponse.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>  &nbsp;
&nbsp;<A HREF="HttpServletRequest.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: &nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->

<HR>

</BODY>
</HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?