📄 httpservletresponse.java
字号:
/*
* $Id: HttpServletResponse.java,v 1.4 1999/04/20 20:37:48 sahmed Exp $
*
* Copyright (c) 1995-1999 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
* CopyrightVersion 1.0
*/
package javax.servlet.http;
import javax.servlet.ServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
/**
*
* Defines an HTTP servlet response that a servlet running on a
* Web server sends to a client using HTTP. This interface
* allows the servlet's <code>service</code> method to access
* HTTP headers and return data to its client. The servlet engine
* implements this interface.
*
*
* @author Various
* @version $Version$
*
* @see javax.servlet.ServletResponse
*
*/
public interface HttpServletResponse extends ServletResponse {
/**
* Adds the specified cookie to the response. It can be called
* multiple times to set more than one cookie.
*
* @param cookie the Cookie to return to the client
*
*/
public void addCookie(Cookie cookie);
/**
* Checks whether the response message header has a field with
* the specified name.
*
* @param name the header field name
* @return true if the response message header has a field with
* the specified name; false otherwise
*/
public boolean containsHeader(String name);
/**
* 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 should include 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>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.
*
* @param url the url to be encoded.
* @return the encoded URL if encoding is needed; the unchanged URL
* otherwise.
*/
public String encodeURL (String url);
/**
* 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
* should include the logic to determine whether the session ID
* needs to be encoded in the URL. Because the rules for making
* this determination differ from those used to decide whether to
* encode a normal link, this method is seperate from the
* <code>encodeUrl</code> method.
*
* <p>All URLs sent to the HttpServletResponse.sendRedirect
* method should be run through this method. Otherwise, URL
* rewriting canont be used with browsers which do not support
* cookies.
*
* <p>After this method is called, the response should be considered
* to be committed and should not be written to.
*
* @param url the url to be encoded.
* @return the encoded URL if encoding is needed; the unchanged URL
* otherwise.
*
* @see #sendRedirect
* @see #encodeUrl
*/
public String encodeRedirectURL (String url);
/**
* 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 should include 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>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.
*
* @param url the url to be encoded.
* @return the encoded URL if encoding is needed; the unchanged URL
* otherwise.
* @deprecated Use encodeURL(String url)
*/
public String encodeUrl(String url);
/**
* 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
* should include the logic to determine whether the session ID
* needs to be encoded in the URL. Because the rules for making
* this determination differ from those used to decide whether to
* encode a normal link, this method is seperate from the
* <code>encodeUrl</code> method.
*
* <p>All URLs sent to the HttpServletResponse.sendRedirect
* method should be run through this method. Otherwise, URL
* rewriting canont be used with browsers which do not support
* cookies.
*
* @param url the url to be encoded.
* @return the encoded URL if encoding is needed; the unchanged URL
* otherwise.
* @deprecated Use encodeRedirectURL(String url)
*/
public String encodeRedirectUrl(String url);
/**
* Sends an error response to the client using the specified status
* code and descriptive message. If setStatus has previously been
* called, it is reset to the error status code. The message is
* sent as the body of an HTML page, which is returned to the user
* to describe the problem. The page is sent with a default HTML
* header; the message is enclosed in simple body tags
* (<body></body>).
*
* <p>After using this method, the response should be considered
* to be committed and should not be written to.
*
* @param sc the status code
* @param msg the detail message
* @exception IOException If an I/O error has occurred. */
public void sendError(int sc, String msg) throws IOException;
/**
* Sends an error response to the client using the specified
* status code and a default message.
* @param sc the status code
* @exception IOException If an I/O error has occurred.
*/
public void sendError(int sc) throws IOException;
/**
* Sends a temporary redirect response to the client using the
* specified redirect location URL. The URL must be absolute (for
* example, <code><em>https://hostname/path/file.html</em></code>).
* Relative URLs are not permitted here.
*
* @param location the redirect location URL
* @exception IOException If an I/O error has occurred.
*/
public void sendRedirect(String location) throws IOException;
/**
*
* Adds a field to the response header with the given name and
* date-valued field. The date is specified in terms of
* milliseconds since the epoch. If the date field 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.
*
* @param name the name of the header field
* @param value the header field's date value
*
* @see #containsHeader
*/
public void setDateHeader(String name, long date);
/**
*
* Adds a field to the response header with the given name and value.
* If the field 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.
*
* @param name the name of the header field
* @param value the header field's value
*
* @see #containsHeader
*/
public void setHeader(String name, String value);
/**
* Adds a field to the response header with the given name and
* integer value. If the field 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.
*
* @param name the name of the header field
* @param value the header field's integer value
*
* @see #containsHeader
*/
public void setIntHeader(String name, int value);
/**
* Sets the status code for this response. This method is used to
* set the return status code when there is no error (for example,
* for the status codes SC_OK or SC_MOVED_TEMPORARILY). If there
* is an error, the <code>sendError</code> method should be used
* instead.
*
* @param sc the status code
*
* @see #sendError
*/
public void setStatus(int sc);
/**
* Sets the status code and message for this response. If the
* field had already been set, the new value overwrites the
* previous one. The message is sent as the body of an HTML
* page, which is returned to the user to describe the problem.
* The page is sent with a default HTML header; the message
* is enclosed in simple body tags (<body></body>).
*
* @param sc the status code
* @param sm the status message
* @deprecated ambiguous meaning. To send an error with a description
* page, use sendError(int sc, String msg);
*/
public void setStatus(int sc, String sm);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -