response |
Variable name:
response
Interface name:
javax.servlet.http.HttpServletResponse
Extends:
javax.servlet.ServletResponse
Implemented by:
Internal container-dependent class
JSP page type:
Available in both regular JSP pages and error pages
Description
The response variable is assigned a reference to an internal container-dependent class that implements a protocol-dependent interface that extends the javax.servlet.ServletResponse interface. Since HTTP is the only protocol supported by JSP 1.1, the class always implements the javax.servlet.http.HttpServletResponse interface. The method descriptions in this section include the methods from both interfaces.
Constants
    public static final int SC_CONTINUE = 100;
    public static final int SC_SWITCHING_PROTOCOLS = 101;
    public static final int SC_OK = 200;
    public static final int SC_CREATED = 201;
    public static final int SC_ACCEPTED = 202;
    public static final int SC_NON_AUTHORITATIVE_INFORMATION = 203;
    public static final int SC_NO_CONTENT = 204;
    public static final int SC_RESET_CONTENT = 205;
    public static final int SC_PARTIAL_CONTENT = 206;
    public static final int SC_MULTIPLE_CHOICES = 300;
    public static final int SC_MOVED_PERMANENTLY = 301;
    public static final int SC_MOVED_TEMPORARILY = 302;
    public static final int SC_SEE_OTHER = 303;
    public static final int SC_NOT_MODIFIED = 304;
    public static final int SC_USE_PROXY = 305;
    public static final int SC_TEMPORARY_REDIRECT = 307;
    public static final int SC_BAD_REQUEST = 400;
    public static final int SC_UNAUTHORIZED = 401;
    public static final int SC_PAYMENT_REQUIRED = 402;
    public static final int SC_FORBIDDEN = 403;
    public static final int SC_NOT_FOUND = 404;
    public static final int SC_METHOD_NOT_ALLOWED = 405;
    public static final int SC_NOT_ACCEPTABLE = 406;
    public static final int SC_PROXY_AUTHENTICATION_REQUIRED = 407;
    public static final int SC_REQUEST_TIMEOUT = 408;
    public static final int SC_CONFLICT = 409;
    public static final int SC_GONE = 410;
    public static final int SC_LENGTH_REQUIRED = 411;
    public static final int SC_PRECONDITION_FAILED = 412;
    public static final int SC_REQUEST_ENTITY_TOO_LARGE = 413;
    public static final int SC_REQUEST_URI_TOO_LONG = 414;
    public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415;
    public static final int SC_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
    public static final int SC_EXPECTATION_FAILED = 417;
    public static final int SC_INTERNAL_SERVER_ERROR = 500;
    public static final int SC_NOT_IMPLEMENTED = 501;
    public static final int SC_BAD_GATEWAY = 502;
    public static final int SC_SERVICE_UNAVAILABLE = 503;
    public static final int SC_GATEWAY_TIMEOUT = 504;
    public static final int SC_HTTP_VERSION_NOT_SUPPORTED = 505;

addCookie() |
public void addCookie(Cookie cookie)
Adds the specified cookie to the response.

addDateHeader() |
public void addDateHeader(String headername, long date)
Adds a response header with the given name and date value. The date is specified in terms of milliseconds since the epoch ( January 1, 1970, 00:00:00 GMT).

addHeader() |
public void addHeader(String headername, String value)
Adds a response header with the specified name and value.

addIntHeader() |
public void addIntHeader(String headername, int value)
Adds a response header with the given name and integer value.

containsHeader() |
public boolean containsHeader(String name)
Returns a boolean indicating whether the named response header has already been set.

encodeRedirectURL() |
public String encodeRedirectURL(String url)
Encodes the specified URL for use in the sendRedirect() method by including the session ID in it. If encoding (URL rewriting) is not needed, it returns the URL unchanged.

encodeURL() |
public String encodeURL(String url)
Encodes the specified URL for use in a reference element (e.g., <a>) by including the session ID in it. If encoding (URL rewriting) is not needed, it returns the URL unchanged.

flushBuffer() |
public void flushBuffer() throws IOException
Forces any content in the response body buffer to be written to the client.

getBufferSize() |
public int getBufferSize()
Returns the actual buffer size (in bytes) used for the response, or 0 if no buffering is used.

getCharacterEncoding() |
public String getCharacterEncoding()
Returns the name of the charset used for the MIME body sent in this response.

getLocale() |
public Locale getLocale()
Returns the locale assigned to the response. This is either a Locale object for the server's default locale or the Locale set with setLocale().

getOutputStream() |
public ServletOutputStream getOutputStream() throws IOException
Returns a ServletOutputStream suitable for writing binary data in the response. This method should not be used in a JSP page, since JSP pages are intended for text data.

getWriter() |
public PrintWriter getWriter throws IOException
Returns a PrintWriter object that can send character text to the client. This method should not be used in a JSP page, since it may interfere with the container's writer mechanism. Use the PageContext method instead to get the current JspWriter.

isCommitted() |
public boolean isCommitted()
Returns a boolean indicating if the response has been committed.

reset() |
public void reset()
Clears any data that exists in the buffer as well as the status code and headers. If the response has been committed, this method throws an IllegalStateException.

sendError() |
public void sendError(int status) throws IOException
Sends an error response to the client using the specified status. If the response has already been committed, this method throws an IllegalStateException. After you use this method, you should consider the response committed and should not write to it.

sendError() |
public void sendError(int status, String message) throws IOException
Sends an error response to the client using the specified status code and descriptive message. If the response has already been committed, this method throws an IllegalStateException. After you use this method, you should consider the response committed and should not write to it.

sendRedirect() |
public void sendRedirect(String location) throws IOException
Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container will convert the relative URL to an absolute URL before sending the response to the client. If the response is already committed, this method throws an IllegalStateException. After you use this method, you should consider the response committed and should not write to it.

setBufferSize() |
public void setBufferSize(int size)
Sets the preferred buffer size (in bytes) for the body of the response. The servlet container uses a buffer at least as large as the size requested. The actual buffer size used can be found with the getBufferSize() method.

setContentLength() |
public void setContentLength(int length)
Sets the length (in bytes) of the content body in the response. In HTTP servlets, this method sets the HTTP Content-Length header. This method should not be used in a JSP page, since it may interfere with the container's writer mechanism.

setContentType() |
public void setContentType(String type)
Sets the content type of the response being sent to the client.

setDateHeader() |
public void setDateHeader(String headername, long date)
Sets a response header with the given name and date value. The date is specified in terms of milliseconds since the epoch ( January 1, 1970, 00:00:00 GMT). If the header is already set, the new value overwrites the previous one.

setHeader() |
public void setHeader(String headername, String value)
Sets a response header with the given name and value. If the header is already set, the new value overwrites the previous one.

setIntHeader() |
public void setIntHeader(String headername, int value)
Sets a response header with the given name and integer value. If the header is already set, the new value overwrites the previous one.

setLocale() |
public void setLocale(Locale locale)
Sets the locale of the response, setting the headers (including the Content-Type header's charset) as appropriate.

setStatus() |
public void setStatus(int statuscode)
Sets the status code for this response. Unlike the sendError() method, this method only sets the status code; it doesn't add a body and it does not commit the response.

encodeRedirectUrl() | Deprecated
public String encodeRedirectUrl(String url)
As of the Servlet 2.1 API, use encodeRedirectURL(String url) instead.

encodeUrl() | Deprecated
public String encodeUrl(String url)
As of the Servlet 2.1 API, use encodeURL(String url) instead.

setStatus() | Deprecated
public void setStatus(int statuscode, String message)
As of the Servlet 2.1 API, use setStatus(int) to set a status code and sendError(int, String) to send an error with a description. This method was deprecated because of the ambiguous meaning of the message parameter.