📄 httpservletresponse.html
字号:
<PRE>
public 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>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="addCookie(javax.servlet.http.Cookie)"><!-- --></A><H3>
addCookie</H3>
<PRE>
public 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>
public boolean <B>containsHeader</B>(java.lang.String 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>
public java.lang.String <B>encodeURL</B>(java.lang.String 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>
public java.lang.String <B>encodeRedirectURL</B>(java.lang.String 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>
public java.lang.String <B>encodeUrl</B>(java.lang.String 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>
public java.lang.String <B>encodeRedirectUrl</B>(java.lang.String 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>
public void <B>sendError</B>(int sc,
java.lang.String msg)
throws java.io.IOException</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>java.io.IOException</CODE> - If an input or output exception occurs
<DD><CODE>java.lang.IllegalStateException</CODE> - If the response was committed</DL>
</DD>
</DL>
<HR>
<A NAME="sendError(int)"><!-- --></A><H3>
sendError</H3>
<PRE>
public void <B>sendError</B>(int sc)
throws java.io.IOException</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>java.io.IOException</CODE> - If an input or output exception occurs
<DD><CODE>java.lang.IllegalStateException</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>
public void <B>sendRedirect</B>(java.lang.String location)
throws java.io.IOException</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>java.io.IOException</CODE> - If an input or output exception occurs
<DD><CODE>java.lang.IllegalStateException</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.lang.String, long)"><!-- --></A><H3>
setDateHeader</H3>
<PRE>
public void <B>setDateHeader</B>(java.lang.String name,
long date)</PRE>
<DL>
<DD>Sets a response header with the given name and
date-value. The date is specified in terms of
milliseconds since the epoch. If the header had already
been set, the new value overwrites the previous one. The
<code>containsHeader</code> method can be used to test for the
presence of a header before setting its value.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - the name of the header to set<DD><CODE>date</CODE> - the assigned date value<DT><B>See Also:</B><DD><A HREF="../../../javax/servlet/http/HttpServletResponse.html#containsHeader(java.lang.String)"><CODE>containsHeader(java.lang.String)</CODE></A>,
<A HREF="../../../javax/servlet/http/HttpServletResponse.html#addDateHeader(java.lang.String, long)"><CODE>addDateHeader(java.lang.String, long)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="addDateHeader(java.lang.String, long)"><!-- --></A><H3>
addDateHeader</H3>
<PRE>
public void <B>addDateHeader</B>(java.lang.String name,
long date)</PRE>
<DL>
<DD>Adds a response header with the given name and
date-value. The date is specified in terms of
milliseconds since the epoch. This method allows response headers
to have multiple values.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - the name of the header to set<DD><CODE>date</CODE> - the additional date value<DT><B>See Also:</B><DD><A HREF="../../../javax/servlet/http/HttpServletResponse.html#setDateHeader(java.lang.String, long)"><CODE>setDateHeader(java.lang.String, long)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="setHeader(java.lang.String, java.lang.String)"><!-- --></A><H3>
setHeader</H3>
<PRE>
public void <B>setHeader</B>(java.lang.String name,
java.lang.String value)</PRE>
<DL>
<DD>Sets a response header with the given name and value.
If the header had already been set, the new value overwrites the
previous one. The <code>containsHeader</code> method can be
used to test for the presence of a header before setting its
value.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -