servletrequest.html

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

HTML
832
字号
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/servlet/ServletRequest.html#getServerName()">getServerName</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the host name of the server that received the request.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/servlet/ServletRequest.html#getServerPort()">getServerPort</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the port number on which this request was received.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/servlet/ServletRequest.html#isSecure()">isSecure</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a boolean indicating whether this request was made using a
 secure channel, such as HTTPS.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/servlet/ServletRequest.html#removeAttribute(java.lang.String)">removeAttribute</A></B>(java.lang.String&nbsp;name)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Removes an attribute from this request.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/servlet/ServletRequest.html#setAttribute(java.lang.String, java.lang.Object)">setAttribute</A></B>(java.lang.String&nbsp;name,
             java.lang.Object&nbsp;o)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stores an attribute in this request.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/servlet/ServletRequest.html#setCharacterEncoding(java.lang.String)">setCharacterEncoding</A></B>(java.lang.String&nbsp;env)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Overrides the name of the character encoding used in the body of this
 request.</TD>
</TR>
</TABLE>
&nbsp;
<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="getAttribute(java.lang.String)"><!-- --></A><H3>
getAttribute</H3>
<PRE>
public java.lang.Object <B>getAttribute</B>(java.lang.String&nbsp;name)</PRE>
<DL>
<DD>Returns the value of the named attribute as an <code>Object</code>,
 or <code>null</code> if no attribute of the given name exists. 

 <p> Attributes can be set two ways.  The servlet container may set
 attributes to make available custom information about a request.
 For example, for requests made using HTTPS, the attribute
 <code>javax.servlet.request.X509Certificate</code> can be used to
 retrieve information on the certificate of the client.  Attributes
 can also be set programatically using 
 <A HREF="../../javax/servlet/ServletRequest.html#setAttribute(java.lang.String, java.lang.Object)"><CODE>setAttribute(java.lang.String, java.lang.Object)</CODE></A>.  This allows information to be
 embedded into a request before a <A HREF="../../javax/servlet/RequestDispatcher.html"><CODE>RequestDispatcher</CODE></A> call.

 <p>Attribute names should follow the same conventions as package
 names. This specification reserves names matching <code>java.*</code>,
 <code>javax.*</code>, and <code>sun.*</code>.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - a <code>String</code> specifying the name of 
			the attribute<DT><B>Returns:</B><DD>an <code>Object</code> containing the value 
			of the attribute, or <code>null</code> if
			the attribute does not exist</DL>
</DD>
</DL>
<HR>

<A NAME="getAttributeNames()"><!-- --></A><H3>
getAttributeNames</H3>
<PRE>
public java.util.Enumeration <B>getAttributeNames</B>()</PRE>
<DL>
<DD>Returns an <code>Enumeration</code> containing the
 names of the attributes available to this request. 
 This method returns an empty <code>Enumeration</code>
 if the request has no attributes available to it.<DD><DL>
<DT><B>Returns:</B><DD>an <code>Enumeration</code> of strings 
			containing the names 
 			of the request's attributes</DL>
</DD>
</DL>
<HR>

<A NAME="getCharacterEncoding()"><!-- --></A><H3>
getCharacterEncoding</H3>
<PRE>
public java.lang.String <B>getCharacterEncoding</B>()</PRE>
<DL>
<DD>Returns the name of the character encoding used in the body of this
 request. This method returns <code>null</code> if the request
 does not specify a character encoding<DD><DL>
<DT><B>Returns:</B><DD>a <code>String</code> containing the name of 
			the chararacter encoding, or <code>null</code>
			if the request does not specify a character encoding</DL>
</DD>
</DL>
<HR>

<A NAME="setCharacterEncoding(java.lang.String)"><!-- --></A><H3>
setCharacterEncoding</H3>
<PRE>
public void <B>setCharacterEncoding</B>(java.lang.String&nbsp;env)
                          throws java.io.UnsupportedEncodingException</PRE>
<DL>
<DD>Overrides the name of the character encoding used in the body of this
 request. This method must be called prior to reading request parameters
 or reading input using getReader().<DD><DL>
<DT><B>Parameters:</B><DD><CODE>a</CODE> - <code>String</code> containing the name of 
			the chararacter encoding.<DT><B>Throws:</B><DD><CODE>java.io.UnsupportedEncodingException</CODE> - if this is not a valid encoding</DL>
</DD>
</DL>
<HR>

<A NAME="getContentLength()"><!-- --></A><H3>
getContentLength</H3>
<PRE>
public int <B>getContentLength</B>()</PRE>
<DL>
<DD>Returns the length, in bytes, of the request body 
 and made available by the input stream, or -1 if the
 length is not known. For HTTP servlets, same as the value
 of the CGI variable CONTENT_LENGTH.<DD><DL>
<DT><B>Returns:</B><DD>an integer containing the length of the 
 			request body or -1 if the length is not known</DL>
</DD>
</DL>
<HR>

<A NAME="getContentType()"><!-- --></A><H3>
getContentType</H3>
<PRE>
public java.lang.String <B>getContentType</B>()</PRE>
<DL>
<DD>Returns the MIME type of the body of the request, or 
 <code>null</code> if the type is not known. For HTTP servlets, 
 same as the value of the CGI variable CONTENT_TYPE.<DD><DL>
<DT><B>Returns:</B><DD>a <code>String</code> containing the name 
			of the MIME type of 
 			the request, or null if the type is not known</DL>
</DD>
</DL>
<HR>

<A NAME="getInputStream()"><!-- --></A><H3>
getInputStream</H3>
<PRE>
public <A HREF="../../javax/servlet/ServletInputStream.html">ServletInputStream</A> <B>getInputStream</B>()
                                  throws java.io.IOException</PRE>
<DL>
<DD>Retrieves the body of the request as binary data using
 a <A HREF="../../javax/servlet/ServletInputStream.html"><CODE>ServletInputStream</CODE></A>.  Either this method or 
 <A HREF="../../javax/servlet/ServletRequest.html#getReader()"><CODE>getReader()</CODE></A> may be called to read the body, not both.<DD><DL>
<DT><B>Returns:</B><DD>a <A HREF="../../javax/servlet/ServletInputStream.html"><CODE>ServletInputStream</CODE></A> object containing
 				the body of the request<DT><B>Throws:</B><DD><CODE>java.lang.IllegalStateException</CODE> - if the <A HREF="../../javax/servlet/ServletRequest.html#getReader()"><CODE>getReader()</CODE></A> method
 					 has already been called for this request<DD><CODE>java.io.IOException</CODE> - if an input or output exception occurred</DL>
</DD>
</DL>
<HR>

<A NAME="getParameter(java.lang.String)"><!-- --></A><H3>
getParameter</H3>
<PRE>
public java.lang.String <B>getParameter</B>(java.lang.String&nbsp;name)</PRE>
<DL>
<DD>Returns the value of a request parameter as a <code>String</code>,
 or <code>null</code> if the parameter does not exist. Request parameters
 are extra information sent with the request.  For HTTP servlets,
 parameters are contained in the query string or posted form data.

 <p>You should only use this method when you are sure the
 parameter has only one value. If the parameter might have
 more than one value, use <A HREF="../../javax/servlet/ServletRequest.html#getParameterValues(java.lang.String)"><CODE>getParameterValues(java.lang.String)</CODE></A>.

 <p>If you use this method with a multivalued
 parameter, the value returned is equal to the first value
 in the array returned by <code>getParameterValues</code>.

 <p>If the parameter data was sent in the request body, such as occurs
 with an HTTP POST request, then reading the body directly via <A HREF="../../javax/servlet/ServletRequest.html#getInputStream()"><CODE>getInputStream()</CODE></A> or <A HREF="../../javax/servlet/ServletRequest.html#getReader()"><CODE>getReader()</CODE></A> can interfere
 with the execution of this method.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - a <code>String</code> specifying the 
			name of the parameter<DT><B>Returns:</B><DD>a <code>String</code> representing the 
			single value of the parameter<DT><B>See Also: </B><DD><A HREF="../../javax/servlet/ServletRequest.html#getParameterValues(java.lang.String)"><CODE>getParameterValues(java.lang.String)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getParameterNames()"><!-- --></A><H3>
getParameterNames</H3>
<PRE>
public java.util.Enumeration <B>getParameterNames</B>()</PRE>
<DL>
<DD>Returns an <code>Enumeration</code> of <code>String</code>
 objects containing the names of the parameters contained
 in this request. If the request has 
 no parameters, the method returns an 
 empty <code>Enumeration</code>.<DD><DL>
<DT><B>Returns:</B><DD>an <code>Enumeration</code> of <code>String</code>
			objects, each <code>String</code> containing
 			the name of a request parameter; or an 
			empty <code>Enumeration</code> if the
			request has no parameters</DL>
</DD>
</DL>
<HR>

<A NAME="getParameterValues(java.lang.String)"><!-- --></A><H3>
getParameterValues</H3>
<PRE>
public java.lang.String[] <B>getParameterValues</B>(java.lang.String&nbsp;name)</PRE>
<DL>
<DD>Returns an array of <code>String</code> objects containing 
 all of the values the given request parameter has, or 
 <code>null</code> if the parameter does not exist.

 <p>If the parameter has a single value, the array has a length
 of 1.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - a <code>String</code> containing the name of 
			the parameter whose value is requested<DT><B>Returns:</B><DD>an array of <code>String</code> objects 
			containing the parameter's values<DT><B>See Also: </B><DD><A HREF="../../javax/servlet/ServletRequest.html#getParameter(java.lang.String)"><CODE>getParameter(java.lang.String)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getParameterMap()"><!-- --></A><H3>
getParameterMap</H3>
<PRE>
public java.util.Map <B>getParameterMap</B>()</PRE>
<DL>
<DD>Returns a java.util.Map of the parameters of this request.
 Request parameters
 are extra information sent with the request.  For HTTP servlets,
 parameters are contained in the query string or posted form data.<DD><DL>
<DT><B>Returns:</B><DD>an immutable java.util.Map containing parameter names as 
 keys and parameter values as map values. The keys in the parameter
 map are of type String. The values in the parameter map are of type
 String array.</DL>
</DD>
</DL>
<HR>

<A NAME="getProtocol()"><!-- --></A><H3>
getProtocol</H3>
<PRE>
public java.lang.String <B>getProtocol</B>()</PRE>

⌨️ 快捷键说明

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