Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.servlet.http
Interface HttpServletResponse

public interface HttpServletResponse
extends ServletResponse

HttpServletResponse extends ServletResponse allowing servlets to set the status and headers.

#### Useful Headers

Expires | Lets clients cache the page. Resin can use Expires to internally cache the page.

Field Summary
`static int` | `SC_ACCEPTED`
`static int` | `SC_BAD_GATEWAY`
`static int` | `SC_BAD_REQUEST`
`static int` | `SC_CONFLICT`
`static int` | `SC_CONTINUE`
`static int` | `SC_CREATED`
`static int` | `SC_EXPECTATION_FAILED`
`static int` | `SC_FORBIDDEN`
`static int` | `SC_GATEWAY_TIMEOUT`
`static int` | `SC_GONE`
`static int` | `SC_HTTP_VERSION_NOT_SUPPORTED`
`static int` | `SC_INTERNAL_SERVER_ERROR`
`static int` | `SC_LENGTH_REQUIRED`
`static int` | `SC_METHOD_NOT_ALLOWED`
`static int` | `SC_MOVED_PERMANENTLY`
`static int` | `SC_MOVED_TEMPORARILY`
`static int` | `SC_MULTIPLE_CHOICES`
`static int` | `SC_NO_CONTENT`
`static int` | `SC_NON_AUTHORITATIVE_INFORMATION`
`static int` | `SC_NOT_ACCEPTABLE`
`static int` | `SC_NOT_FOUND`
`static int` | `SC_NOT_IMPLEMENTED`
`static int` | `SC_NOT_MODIFIED`
`static int` | `SC_OK`
`static int` | `SC_PARTIAL_CONTENT`
`static int` | `SC_PAYMENT_REQUIRED`
`static int` | `SC_PRECONDITION_FAILED`
`static int` | `SC_PROXY_AUTHENTICATION_REQUIRED`
`static int` | `SC_REQUEST_ENTITY_TOO_LARGE`
`static int` | `SC_REQUEST_TIMEOUT`
`static int` | `SC_REQUEST_URI_TOO_LONG`
`static int` | `SC_REQUESTED_RANGE_NOT_SATISFIABLE`
`static int` | `SC_RESET_CONTENT`
`static int` | `SC_SEE_OTHER`
`static int` | `SC_SERVICE_UNAVAILABLE`
`static int` | `SC_SWITCHING_PROCOTOLS`
`static int` | `SC_UNAUTHORIZED`
`static int` | `SC_UNSUPPORTED_MEDIA_TYPE`
`static int` | `SC_USE_PROXY_TYPE`

Method Summary
`void` | `addCookie(Cookie cookie)` Sends a new cookie to the client.
`void` | `addDateHeader(java.lang.String name, long date)` Adds a header by converting a date to a string.
`void` | `addHeader(java.lang.String name, java.lang.String value)` Adds a header.
`void` | `addIntHeader(java.lang.String name, int value)` Adds a header by converting an integer value to a string.
`boolean` | `containsHeader(java.lang.String name)` Returns true if the output headers include `name`
`java.lang.String` | `encodeRedirectUrl(java.lang.String url)` Deprecated.
`java.lang.String` | `encodeRedirectURL(java.lang.String name)` Encodes session information in a url suitable for `sendRedirect()`
`java.lang.String` | `encodeUrl(java.lang.String url)` Deprecated.
`java.lang.String` | `encodeURL(java.lang.String url)` Encodes session information in a url.
`void` | `sendError(int sc)` Sends an HTTP error page based on the status code
`void` | `sendError(int sc, java.lang.String msg)` Sends an HTTP error page based on the status code
`void` | `sendRedirect(java.lang.String location)` Redirects the client to another page.
`void` | `setDateHeader(java.lang.String name, long date)` Sets a header by converting a date to a string.
`void` | `setHeader(java.lang.String name, java.lang.String value)` Sets a header.
`void` | `setIntHeader(java.lang.String name, int value)` Sets a header by converting an integer value to a string.
`void` | `setStatus(int sc)` Sets the HTTP status
`void` | `setStatus(int sc, java.lang.String msg)` Deprecated.

Methods inherited from interface javax.servlet.ServletResponse
`flushBuffer, getBufferSize, getCharacterEncoding, getLocale, getOutputStream, getWriter, isCommitted, reset, setBufferSize, setContentLength, setContentType, setLocale`

Field Detail

### SC_ACCEPTED

    public static final int SC_ACCEPTED

### SC_BAD_GATEWAY

    public static final int SC_BAD_GATEWAY

### SC_BAD_REQUEST

    public static final int SC_BAD_REQUEST

### SC_CONFLICT

    public static final int SC_CONFLICT

### SC_CONTINUE

    public static final int SC_CONTINUE

### SC_CREATED

    public static final int SC_CREATED

### SC_EXPECTATION_FAILED

    public static final int SC_EXPECTATION_FAILED

### SC_FORBIDDEN

    public static final int SC_FORBIDDEN

### SC_GATEWAY_TIMEOUT

    public static final int SC_GATEWAY_TIMEOUT

### SC_GONE

    public static final int SC_GONE

### SC_HTTP_VERSION_NOT_SUPPORTED

    public static final int SC_HTTP_VERSION_NOT_SUPPORTED

### SC_INTERNAL_SERVER_ERROR

    public static final int SC_INTERNAL_SERVER_ERROR

### SC_LENGTH_REQUIRED

    public static final int SC_LENGTH_REQUIRED

### SC_METHOD_NOT_ALLOWED

    public static final int SC_METHOD_NOT_ALLOWED

### SC_MOVED_PERMANENTLY

    public static final int SC_MOVED_PERMANENTLY

### SC_MOVED_TEMPORARILY

    public static final int SC_MOVED_TEMPORARILY

### SC_MULTIPLE_CHOICES

    public static final int SC_MULTIPLE_CHOICES

### SC_NO_CONTENT

    public static final int SC_NO_CONTENT

### SC_NON_AUTHORITATIVE_INFORMATION

    public static final int SC_NON_AUTHORITATIVE_INFORMATION

### SC_NOT_ACCEPTABLE

    public static final int SC_NOT_ACCEPTABLE

### SC_NOT_FOUND

    public static final int SC_NOT_FOUND

### SC_NOT_IMPLEMENTED

    public static final int SC_NOT_IMPLEMENTED

### SC_NOT_MODIFIED

    public static final int SC_NOT_MODIFIED

### SC_OK

    public static final int SC_OK

### SC_PARTIAL_CONTENT

    public static final int SC_PARTIAL_CONTENT

### SC_PAYMENT_REQUIRED

    public static final int SC_PAYMENT_REQUIRED

### SC_PRECONDITION_FAILED

    public static final int SC_PRECONDITION_FAILED

### SC_PROXY_AUTHENTICATION_REQUIRED

    public static final int SC_PROXY_AUTHENTICATION_REQUIRED

### SC_REQUEST_ENTITY_TOO_LARGE

    public static final int SC_REQUEST_ENTITY_TOO_LARGE

### SC_REQUEST_TIMEOUT

    public static final int SC_REQUEST_TIMEOUT

### SC_REQUEST_URI_TOO_LONG

    public static final int SC_REQUEST_URI_TOO_LONG

### SC_REQUESTED_RANGE_NOT_SATISFIABLE

    public static final int SC_REQUESTED_RANGE_NOT_SATISFIABLE

### SC_RESET_CONTENT

    public static final int SC_RESET_CONTENT

### SC_SEE_OTHER

    public static final int SC_SEE_OTHER

### SC_SERVICE_UNAVAILABLE

    public static final int SC_SERVICE_UNAVAILABLE

### SC_SWITCHING_PROCOTOLS

    public static final int SC_SWITCHING_PROCOTOLS

### SC_UNAUTHORIZED

    public static final int SC_UNAUTHORIZED

### SC_UNSUPPORTED_MEDIA_TYPE

    public static final int SC_UNSUPPORTED_MEDIA_TYPE

### SC_USE_PROXY_TYPE

    public static final int SC_USE_PROXY_TYPE

Method Detail

### setStatus

    public void setStatus(int sc)

  Sets the HTTP status
  Parameters:
    `sc` - the HTTP status code

### sendError

    public void sendError(int sc,
                          java.lang.String msg)
                   throws java.io.IOException

  Sends an HTTP error page based on the status code
  Parameters:
    `sc` - the HTTP status code

### sendError

    public void sendError(int sc)
                   throws java.io.IOException

  Sends an HTTP error page based on the status code
  Parameters:
    `sc` - the HTTP status code

### sendRedirect

    public void sendRedirect(java.lang.String location)
                      throws java.io.IOException

  Redirects the client to another page.
  Parameters:
    `location` - the location to redirect to.

### setHeader

    public void setHeader(java.lang.String name,
                          java.lang.String value)

  Sets a header. This will override a previous header with the same name.
  Parameters:
    `name` - the header name
    `value` - the header value

### addHeader

    public void addHeader(java.lang.String name,
                          java.lang.String value)

  Adds a header. If another header with the same name exists, both will be sent to the client.
  Parameters:
    `name` - the header name
    `value` - the header value

### containsHeader

    public boolean containsHeader(java.lang.String name)

  Returns true if the output headers include `name`
  Parameters:
    `name` - the header name to test

### setDateHeader

    public void setDateHeader(java.lang.String name,
                              long date)

  Sets a header by converting a date to a string.

  To set the page to expire in 15 seconds use the following:

       long now = System.currentTime();
       response.setDateHeader("Expires", now + 15000);

  Parameters:
    `name` - name of the header
    `date` - the date in milliseconds since the epoch.

### addDateHeader

    public void addDateHeader(java.lang.String name,
                              long date)

  Adds a header by converting a date to a string.
  Parameters:
    `name` - name of the header
    `date` - the date in milliseconds since the epoch.

### setIntHeader

    public void setIntHeader(java.lang.String name,
                             int value)

  Sets a header by converting an integer value to a string.
  Parameters:
    `name` - name of the header
    `value` - the value as an integer

### addIntHeader

    public void addIntHeader(java.lang.String name,
                             int value)

  Adds a header by converting an integer value to a string.
  Parameters:
    `name` - name of the header
    `value` - the value as an integer

### addCookie

    public void addCookie(Cookie cookie)

  Sends a new cookie to the client.

### encodeURL

    public java.lang.String encodeURL(java.lang.String url)

  Encodes session information in a url.
  Parameters:
    `url` - the url to encode
  Returns:
    a url with session information encoded

### encodeRedirectURL

    public java.lang.String encodeRedirectURL(java.lang.String name)

  Encodes session information in a url suitable for `sendRedirect()`
  Parameters:
    `url` - the url to encode
  Returns:
    a url with session information encoded

### setStatus

    public void setStatus(int sc,
                          java.lang.String msg)

  Deprecated.

### encodeUrl

    public java.lang.String encodeUrl(java.lang.String url)

  Deprecated.

### encodeRedirectUrl

    public java.lang.String encodeRedirectUrl(java.lang.String url)

  Deprecated.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD