📄 httpservletresponse.html
字号:
<DD>Status code (501) indicating the HTTP server does not support the functionality needed to fulfill the request.<P><DL><DT><B>See Also:</B><DD><A HREF="../../../constant-values.html#javax.servlet.http.HttpServletResponse.SC_NOT_IMPLEMENTED">Constant Field Values</A></DL></DL><HR><A NAME="SC_BAD_GATEWAY"><!-- --></A><H3>SC_BAD_GATEWAY</H3><PRE>static final int <B>SC_BAD_GATEWAY</B></PRE><DL><DD>Status code (502) indicating that the HTTP server received an invalid response from a server it consulted when acting as a proxy or gateway.<P><DL><DT><B>See Also:</B><DD><A HREF="../../../constant-values.html#javax.servlet.http.HttpServletResponse.SC_BAD_GATEWAY">Constant Field Values</A></DL></DL><HR><A NAME="SC_SERVICE_UNAVAILABLE"><!-- --></A><H3>SC_SERVICE_UNAVAILABLE</H3><PRE>static final int <B>SC_SERVICE_UNAVAILABLE</B></PRE><DL><DD>Status code (503) indicating that the HTTP server is temporarily overloaded, and unable to handle the request.<P><DL><DT><B>See Also:</B><DD><A HREF="../../../constant-values.html#javax.servlet.http.HttpServletResponse.SC_SERVICE_UNAVAILABLE">Constant Field Values</A></DL></DL><HR><A NAME="SC_GATEWAY_TIMEOUT"><!-- --></A><H3>SC_GATEWAY_TIMEOUT</H3><PRE>static final int <B>SC_GATEWAY_TIMEOUT</B></PRE><DL><DD>Status code (504) indicating that the server did not receive a timely response from the upstream server while acting as a gateway or proxy.<P><DL><DT><B>See Also:</B><DD><A HREF="../../../constant-values.html#javax.servlet.http.HttpServletResponse.SC_GATEWAY_TIMEOUT">Constant Field Values</A></DL></DL><HR><A NAME="SC_HTTP_VERSION_NOT_SUPPORTED"><!-- --></A><H3>SC_HTTP_VERSION_NOT_SUPPORTED</H3><PRE>static final int <B>SC_HTTP_VERSION_NOT_SUPPORTED</B></PRE><DL><DD>Status code (505) indicating that the server does not support or refuses to support the HTTP protocol version that was used in the request message.<P><DL><DT><B>See Also:</B><DD><A HREF="../../../constant-values.html#javax.servlet.http.HttpServletResponse.SC_HTTP_VERSION_NOT_SUPPORTED">Constant Field Values</A></DL></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>Method Detail</B></FONT></TH></TR></TABLE><A NAME="addCookie(javax.servlet.http.Cookie)"><!-- --></A><H3>addCookie</H3><PRE>void <B>addCookie</B>(<A HREF="../../../javax/servlet/http/Cookie.html" title="class in javax.servlet.http">Cookie</A> cookie)</PRE><DL><DD>Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>cookie</CODE> - the Cookie to return to the client</DL></DD></DL><HR><A NAME="containsHeader(java.lang.String)"><!-- --></A><H3>containsHeader</H3><PRE>boolean <B>containsHeader</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 a boolean indicating whether the named response header has already been set.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - the header name<DT><B>Returns:</B><DD><code>true</code> if the named response header has already been set; <code>false</code> otherwise</DL></DD></DL><HR><A NAME="encodeURL(java.lang.String)"><!-- --></A><H3>encodeURL</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>encodeURL</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> url)</PRE><DL><DD>Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. For example, if the browser supports cookies, or session tracking is turned off, URL encoding is unnecessary. <p>For robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>url</CODE> - the url to be encoded.<DT><B>Returns:</B><DD>the encoded URL if encoding is needed; the unchanged URL otherwise.</DL></DD></DL><HR><A NAME="encodeRedirectURL(java.lang.String)"><!-- --></A><H3>encodeRedirectURL</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>encodeRedirectURL</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> url)</PRE><DL><DD>Encodes the specified URL for use in the <code>sendRedirect</code> method or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. Because the rules for making this determination can differ from those used to decide whether to encode a normal link, this method is separated from the <code>encodeURL</code> method. <p>All URLs sent to the <code>HttpServletResponse.sendRedirect</code> method should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>url</CODE> - the url to be encoded.<DT><B>Returns:</B><DD>the encoded URL if encoding is needed; the unchanged URL otherwise.<DT><B>See Also:</B><DD><A HREF="../../../javax/servlet/http/HttpServletResponse.html#sendRedirect(java.lang.String)"><CODE>sendRedirect(java.lang.String)</CODE></A>, <A HREF="../../../javax/servlet/http/HttpServletResponse.html#encodeUrl(java.lang.String)"><CODE>encodeUrl(java.lang.String)</CODE></A></DL></DD></DL><HR><A NAME="encodeUrl(java.lang.String)"><!-- --></A><H3>encodeUrl</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>encodeUrl</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> url)</PRE><DL><DD><B>Deprecated.</B> <I>As of version 2.1, use encodeURL(String url) instead</I><P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>url</CODE> - the url to be encoded.<DT><B>Returns:</B><DD>the encoded URL if encoding is needed; the unchanged URL otherwise.</DL></DD></DL><HR><A NAME="encodeRedirectUrl(java.lang.String)"><!-- --></A><H3>encodeRedirectUrl</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>encodeRedirectUrl</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> url)</PRE><DL><DD><B>Deprecated.</B> <I>As of version 2.1, use encodeRedirectURL(String url) instead</I><P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>url</CODE> - the url to be encoded.<DT><B>Returns:</B><DD>the encoded URL if encoding is needed; the unchanged URL otherwise.</DL></DD></DL><HR><A NAME="sendError(int, java.lang.String)"><!-- --></A><H3>sendError</H3><PRE>void <B>sendError</B>(int sc, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> msg) 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>Sends an error response to the client using the specified status. The server defaults to creating the response to look like an HTML-formatted server error page containing the specified message, setting the content type to "text/html", leaving cookies and other headers unmodified. If an error-page declaration has been made for the web application corresponding to the status code passed in, it will be served back in preference to the suggested msg parameter. <p>If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>sc</CODE> - the error status code<DD><CODE>msg</CODE> - the descriptive message<DT><B>Throws:</B><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 occurs<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 response was committed</DL></DD></DL><HR><A NAME="sendError(int)"><!-- --></A><H3>sendError</H3><PRE>void <B>sendError</B>(int sc) 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>Sends an error response to the client using the specified status code and clearing the buffer. <p>If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>sc</CODE> - the error status code<DT><B>Throws:</B><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 occurs<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 response was committed before this method call</DL></DD></DL><HR><A NAME="sendRedirect(java.lang.String)"><!-- --></A><H3>sendRedirect</H3><PRE>void <B>sendRedirect</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> location) 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>Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root. <p>If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>location</CODE> - the redirect location URL<DT><B>Throws:</B><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 occurs<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 response was committed or if a partial URL is given and cannot be converted into a valid URL</DL></DD></DL><HR><A NAME="setDateHeader(java.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -