📄 servletrequest.java
字号:
public String getScheme(); /** * 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. * * @return a <code>String</code> containing the name * of the server */ public String getServerName(); /** * 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. * * @return an integer specifying the port number * */ public int getServerPort(); /** * 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 {@link #getInputStream} may be called to read the * body, not both. * * * @return a <code>BufferedReader</code> * containing the body of the request * * @exception UnsupportedEncodingException if the character set encoding * used is not supported and the * text cannot be decoded * * @exception IllegalStateException if {@link #getInputStream} method * has been called on this request * * @exception IOException if an input or output exception occurred * * @see #getInputStream * */ public BufferedReader getReader() throws IOException; /** * 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>. * * @return a <code>String</code> containing the * IP address of the client that sent the request * */ public String getRemoteAddr(); /** * 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>. * * @return a <code>String</code> containing the fully * qualified name of the client * */ public String getRemoteHost(); /** * * Stores an attribute in this request. * Attributes are reset between requests. This method is most * often used in conjunction with {@link RequestDispatcher}. * * <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 {@link #removeAttribute}. * <br> It is warned that when the request is dispatched from the * servlet resides in a different web application by * <code>RequestDispatcher</code>, the object set by this method * may not be correctly retrieved in the caller servlet. * * * @param name a <code>String</code> specifying * the name of the attribute * * @param o the <code>Object</code> to be stored * */ public void setAttribute(String name, Object o); /** * * Removes an attribute from this request. This method is not * generally needed as attributes only persist as long as the request * is being handled. * * <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. * * * @param name a <code>String</code> specifying * the name of the attribute to remove * */ public void removeAttribute(String name); /** * * Returns the preferred <code>Locale</code> that the client will * accept content in, based on the Accept-Language header. * If the client request doesn't provide an Accept-Language header, * this method returns the default locale for the server. * * * @return the preferred <code>Locale</code> for the client * */ public Locale getLocale(); /** * * Returns an <code>Enumeration</code> of <code>Locale</code> objects * indicating, in decreasing order starting with the preferred locale, the * locales that are acceptable to the client based on the Accept-Language * header. * If the client request doesn't provide an Accept-Language header, * this method returns an <code>Enumeration</code> containing one * <code>Locale</code>, the default locale for the server. * * * @return an <code>Enumeration</code> of preferred * <code>Locale</code> objects for the client * */ public Enumeration getLocales(); /** * * Returns a boolean indicating whether this request was made using a * secure channel, such as HTTPS. * * * @return a boolean indicating if the request was made using a * secure channel * */ public boolean isSecure(); /** * * Returns a {@link RequestDispatcher} object that acts as a wrapper for * the resource located at the given path. * A <code>RequestDispatcher</code> object can be used to forward * a request to the resource or to include the resource in a response. * The resource can be dynamic or static. * * <p>The pathname specified may be relative, although it cannot extend * outside the current servlet context. If the path begins with * a "/" it is interpreted as relative to the current context root. * This method returns <code>null</code> if the servlet container * cannot return a <code>RequestDispatcher</code>. * * <p>The difference between this method and {@link * ServletContext#getRequestDispatcher} is that this method can take a * relative path. * * @param path a <code>String</code> specifying the pathname * to the resource. If it is relative, it must be * relative against the current servlet. * * @return a <code>RequestDispatcher</code> object * that acts as a wrapper for the resource * at the specified path, or <code>null</code> * if the servlet container cannot return a * <code>RequestDispatcher</code> * * @see RequestDispatcher * @see ServletContext#getRequestDispatcher * */ public RequestDispatcher getRequestDispatcher(String path); /** * * @deprecated As of Version 2.1 of the Java Servlet API, * use {@link ServletContext#getRealPath} instead. * */ public String getRealPath(String path); /** * Returns the Internet Protocol (IP) source port of the client * or last proxy that sent the request. * * @return an integer specifying the port number * * @since 2.4 */ public int getRemotePort(); /** * Returns the host name of the Internet Protocol (IP) interface on * which the request was received. * * @return a <code>String</code> containing the host * name of the IP on which the request was received. * * @since 2.4 */ public String getLocalName(); /** * Returns the Internet Protocol (IP) address of the interface on * which the request was received. * * @return a <code>String</code> containing the * IP address on which the request was received. * * @since 2.4 * */ public String getLocalAddr(); /** * Returns the Internet Protocol (IP) port number of the interface * on which the request was received. * * @return an integer specifying the port number * * @since 2.4 */ public int getLocalPort();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -