📄 servletrequest.html
字号:
<A HREF="../../javax/servlet/ServletInputStream.html" title="class in javax.servlet">ServletInputStream</A> <B>getInputStream</B>() throws <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></PRE><DL><DD>Retrieves the body of the request as binary data using a <A HREF="../../javax/servlet/ServletInputStream.html" title="class in javax.servlet"><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.<P><DD><DL><DT><B>Returns:</B><DD>a <A HREF="../../javax/servlet/ServletInputStream.html" title="class in javax.servlet"><CODE>ServletInputStream</CODE></A> object containing the body of the request<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/IllegalStateException.html" title="class or interface in java.lang">IllegalStateException</A></CODE> - if the <A HREF="../../javax/servlet/ServletRequest.html#getReader()"><CODE>getReader()</CODE></A> method has already been called for this request<DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></CODE> - if an input or output exception occurred</DL></DD></DL><HR><A NAME="getParameter(java.lang.String)"><!-- --></A><H3>getParameter</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getParameter</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> 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.<P><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><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/util/Enumeration.html" title="class or interface in java.util">Enumeration</A> <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>.<P><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><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>[] <B>getParameterValues</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> 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.<P><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><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/util/Map.html" title="class or interface in java.util">Map</A> <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.<P><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><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getProtocol</B>()</PRE><DL><DD>Returns the name and version of the protocol the request uses in the form <i>protocol/majorVersion.minorVersion</i>, for example, HTTP/1.1. For HTTP servlets, the value returned is the same as the value of the CGI variable <code>SERVER_PROTOCOL</code>.<P><DD><DL><DT><B>Returns:</B><DD>a <code>String</code> containing the protocol name and version number</DL></DD></DL><HR><A NAME="getScheme()"><!-- --></A><H3>getScheme</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getScheme</B>()</PRE><DL><DD>Returns the name of the scheme used to make this request, for example, <code>http</code>, <code>https</code>, or <code>ftp</code>. Different schemes have different rules for constructing URLs, as noted in RFC 1738.<P><DD><DL><DT><B>Returns:</B><DD>a <code>String</code> containing the name of the scheme used to make this request</DL></DD></DL><HR><A NAME="getServerName()"><!-- --></A><H3>getServerName</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getServerName</B>()</PRE><DL><DD>Returns the host name of the server to which the request was sent. It is the value of the part before ":" in the <code>Host</code> header value, if any, or the resolved server name, or the server IP address.<P><DD><DL><DT><B>Returns:</B><DD>a <code>String</code> containing the name of the server</DL></DD></DL><HR><A NAME="getServerPort()"><!-- --></A><H3>getServerPort</H3><PRE>int <B>getServerPort</B>()</PRE><DL><DD>Returns the port number to which the request was sent. It is the value of the part after ":" in the <code>Host</code> header value, if any, or the server port where the client connection was accepted on.<P><DD><DL><DT><B>Returns:</B><DD>an integer specifying the port number</DL></DD></DL><HR><A NAME="getReader()"><!-- --></A><H3>getReader</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/BufferedReader.html" title="class or interface in java.io">BufferedReader</A> <B>getReader</B>() throws <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></PRE><DL><DD>Retrieves the body of the request as character data using a <code>BufferedReader</code>. The reader translates the character data according to the character encoding used on the body. Either this method or <A HREF="../../javax/servlet/ServletRequest.html#getInputStream()"><CODE>getInputStream()</CODE></A> may be called to read the body, not both.<P><DD><DL><DT><B>Returns:</B><DD>a <code>BufferedReader</code> containing the body of the request<DT><B>Throws:</B><DD><CODE>UnsupportedEncodingException</CODE> - if the character set encoding used is not supported and the text cannot be decoded<DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/IllegalStateException.html" title="class or interface in java.lang">IllegalStateException</A></CODE> - if <A HREF="../../javax/servlet/ServletRequest.html#getInputStream()"><CODE>getInputStream()</CODE></A> method has been called on this request<DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></CODE> - if an input or output exception occurred<DT><B>See Also:</B><DD><A HREF="../../javax/servlet/ServletRequest.html#getInputStream()"><CODE>getInputStream()</CODE></A></DL></DD></DL><HR><A NAME="getRemoteAddr()"><!-- --></A><H3>getRemoteAddr</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getRemoteAddr</B>()</PRE><DL><DD>Returns the Internet Protocol (IP) address of the client or last proxy that sent the request. For HTTP servlets, same as the value of the CGI variable <code>REMOTE_ADDR</code>.<P><DD><DL><DT><B>Returns:</B><DD>a <code>String</code> containing the IP address of the client that sent the request</DL></DD></DL><HR><A NAME="getRemoteHost()"><!-- --></A><H3>getRemoteHost</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getRemoteHost</B>()</PRE><DL><DD>Returns the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address. For HTTP servlets, same as the value of the CGI variable <code>REMOTE_HOST</code>.<P><DD><DL><DT><B>Returns:</B><DD>a <code>String</code> containing the fully qualified name of the client</DL></DD></DL><HR><A NAME="setAttribute(java.lang.String, java.lang.Object)"><!-- --></A><H3>setAttribute</H3><PRE>void <B>setAttribute</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> name, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A> o)</PRE><DL><DD>Stores an attribute in this request. Attributes are reset between requests. This method is most often used in conjunction with <A HREF="../../javax/servlet/RequestDispatcher.html" title="interface in javax.servlet"><CODE>RequestDispatcher</CODE></A>. <p>Attribute names should follow the same conventions as package names. Names beginning with <code>java.*</code>, <code>javax.*</code>, and <code>com.sun.*</code>, are reserved for use by Sun Microsystems.<br> If the object passed in is null, the effect is the same as calling <A HREF="../../javax/servlet/ServletRequest.html#removeAttribute(java.lang.String)"><CODE>removeAttribute(java.lang.String)</CODE></A>. <br> It is warned that when the request is dispatched from the servlet resides in a different web application by
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -