- All Superinterfaces:
ServletResponse
- All Known Subinterfaces:
WebApplicationResponse
,WebApplicationServerResponse
- All Known Implementing Classes:
DefaultWebApplicationResponse
,DefaultWebApplicationServerResponse
,EmbeddedResponse
,HttpServletResponseWrapper
,NanoResponse
public interface HttpServletResponse extends ServletResponse
The HttpServletResponse API.
- Author:
- Manfred Riem ([email protected])
-
Field Summary
Fields Modifier and Type Field Description static int
SC_ACCEPTED
Defines the 202 status code.static int
SC_BAD_GATEWAY
Defines the 502 status code.static int
SC_BAD_REQUEST
Defines the 400 status code.static int
SC_CONFLICT
Defines the 409 status code.static int
SC_CONTINUE
Defines the 100 status code.static int
SC_CREATED
Defines the 201 status code.static int
SC_EXPECTATION_FAILED
Defines the 417 status code.static int
SC_FORBIDDEN
Defines the 403 status code.static int
SC_FOUND
Defines the 302 status code (recommended variant).static int
SC_GATEWAY_TIMEOUT
Defines the 504 status code.static int
SC_GONE
Defines the 410 status code.static int
SC_HTTP_VERSION_NOT_SUPPORTED
Defines the 505 status code.static int
SC_INTERNAL_SERVER_ERROR
Defines the 500 status code.static int
SC_LENGTH_REQUIRED
Defines the 411 status code.static int
SC_METHOD_NOT_ALLOWED
Defines the 405 status code.static int
SC_MOVED_PERMANENTLY
Defines the 301 status code.static int
SC_MOVED_TEMPORARILY
Defines the 302 status code.static int
SC_MULTIPLE_CHOICES
Defines the 300 status code.static int
SC_NO_CONTENT
Defines the 204 status code.static int
SC_NON_AUTHORITATIVE_INFORMATION
Defines the 203 status code.static int
SC_NOT_ACCEPTABLE
Defines the 406 status code.static int
SC_NOT_FOUND
Defines the 404 status code.static int
SC_NOT_IMPLEMENTED
Defines the 501 status code.static int
SC_NOT_MODIFIED
Defines the 305 status code.static int
SC_OK
Defines the 200 status code.static int
SC_PARTIAL_CONTENT
Defines the 206 status code.static int
SC_PAYMENT_REQUIRED
Defines the 402 status code.static int
SC_PRECONDITION_FAILED
Defines the 412 status code.static int
SC_PROXY_AUTHENTICATION_REQUIRED
Defines the 407 status code.static int
SC_REQUEST_ENTITY_TOO_LARGE
Defines the 413 status code.static int
SC_REQUEST_TIMEOUT
Defines the 408 status code.static int
SC_REQUEST_URI_TOO_LONG
Defines the 414 status code.static int
SC_REQUESTED_RANGE_NOT_SATISFIABLE
Defines the 416 status code.static int
SC_RESET_CONTENT
Defines the 205 status code.static int
SC_SEE_OTHER
Defines the 303 status code.static int
SC_SERVICE_UNAVAILABLE
Defines the 503 status code.static int
SC_SWITCHING_PROTOCOLS
Defines the 101 status code.static int
SC_TEMPORARY_REDIRECT
Defines the 307 status code.static int
SC_UNAUTHORIZED
Defines the 401 status code.static int
SC_UNSUPPORTED_MEDIA_TYPE
Defines the 415 status code.static int
SC_USE_PROXY
Defines the 305 status code. -
Method Summary
Modifier and Type Method Description void
addCookie(Cookie cookie)
Adds the cookie.void
addDateHeader(java.lang.String name, long date)
Add the date header.void
addHeader(java.lang.String name, java.lang.String value)
Add the header.void
addIntHeader(java.lang.String name, int value)
Add the intheader.boolean
containsHeader(java.lang.String name)
Contains the header.java.lang.String
encodeRedirectUrl(java.lang.String url)
Deprecated.java.lang.String
encodeRedirectURL(java.lang.String url)
Encode the redirect URL.java.lang.String
encodeUrl(java.lang.String url)
Deprecated.java.lang.String
encodeURL(java.lang.String url)
Encode the URL.java.lang.String
getHeader(java.lang.String name)
Get the header.java.util.Collection<java.lang.String>
getHeaderNames()
Get the header names.java.util.Collection<java.lang.String>
getHeaders(java.lang.String name)
Get the headers.int
getStatus()
Get the status.default java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.String>>
getTrailerFields()
Get the supplier of trailer fields.void
sendError(int status)
Sends the error.void
sendError(int status, java.lang.String message)
Send the error.void
sendRedirect(java.lang.String location)
Send a redirect.void
setDateHeader(java.lang.String name, long date)
Set the date header.void
setHeader(java.lang.String name, java.lang.String value)
Set the header.void
setIntHeader(java.lang.String name, int value)
Set the int header.void
setStatus(int status)
Set the status.void
setStatus(int status, java.lang.String message)
Deprecated.default void
setTrailerFields(java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.String>> supplier)
Set the trailer fields supplier.Methods inherited from interface javax.servlet.ServletResponse
flushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentLengthLong, setContentType, setLocale
-
Field Details
-
SC_CONTINUE
static final int SC_CONTINUEDefines the 100 status code.- See Also:
- Constant Field Values
-
SC_SWITCHING_PROTOCOLS
static final int SC_SWITCHING_PROTOCOLSDefines the 101 status code.- See Also:
- Constant Field Values
-
SC_OK
static final int SC_OKDefines the 200 status code.- See Also:
- Constant Field Values
-
SC_CREATED
static final int SC_CREATEDDefines the 201 status code.- See Also:
- Constant Field Values
-
SC_ACCEPTED
static final int SC_ACCEPTEDDefines the 202 status code.- See Also:
- Constant Field Values
-
SC_NON_AUTHORITATIVE_INFORMATION
static final int SC_NON_AUTHORITATIVE_INFORMATIONDefines the 203 status code.- See Also:
- Constant Field Values
-
SC_NO_CONTENT
static final int SC_NO_CONTENTDefines the 204 status code.- See Also:
- Constant Field Values
-
SC_RESET_CONTENT
static final int SC_RESET_CONTENTDefines the 205 status code.- See Also:
- Constant Field Values
-
SC_PARTIAL_CONTENT
static final int SC_PARTIAL_CONTENTDefines the 206 status code.- See Also:
- Constant Field Values
-
SC_MULTIPLE_CHOICES
static final int SC_MULTIPLE_CHOICESDefines the 300 status code.- See Also:
- Constant Field Values
-
SC_MOVED_PERMANENTLY
static final int SC_MOVED_PERMANENTLYDefines the 301 status code.- See Also:
- Constant Field Values
-
SC_MOVED_TEMPORARILY
static final int SC_MOVED_TEMPORARILYDefines the 302 status code.- See Also:
- Constant Field Values
-
SC_FOUND
static final int SC_FOUNDDefines the 302 status code (recommended variant).- See Also:
- Constant Field Values
-
SC_SEE_OTHER
static final int SC_SEE_OTHERDefines the 303 status code.- See Also:
- Constant Field Values
-
SC_NOT_MODIFIED
static final int SC_NOT_MODIFIEDDefines the 305 status code.- See Also:
- Constant Field Values
-
SC_USE_PROXY
static final int SC_USE_PROXYDefines the 305 status code.- See Also:
- Constant Field Values
-
SC_TEMPORARY_REDIRECT
static final int SC_TEMPORARY_REDIRECTDefines the 307 status code.- See Also:
- Constant Field Values
-
SC_BAD_REQUEST
static final int SC_BAD_REQUESTDefines the 400 status code.- See Also:
- Constant Field Values
-
SC_UNAUTHORIZED
static final int SC_UNAUTHORIZEDDefines the 401 status code.- See Also:
- Constant Field Values
-
SC_PAYMENT_REQUIRED
static final int SC_PAYMENT_REQUIREDDefines the 402 status code.- See Also:
- Constant Field Values
-
SC_FORBIDDEN
static final int SC_FORBIDDENDefines the 403 status code.- See Also:
- Constant Field Values
-
SC_NOT_FOUND
static final int SC_NOT_FOUNDDefines the 404 status code.- See Also:
- Constant Field Values
-
SC_METHOD_NOT_ALLOWED
static final int SC_METHOD_NOT_ALLOWEDDefines the 405 status code.- See Also:
- Constant Field Values
-
SC_NOT_ACCEPTABLE
static final int SC_NOT_ACCEPTABLEDefines the 406 status code.- See Also:
- Constant Field Values
-
SC_PROXY_AUTHENTICATION_REQUIRED
static final int SC_PROXY_AUTHENTICATION_REQUIREDDefines the 407 status code.- See Also:
- Constant Field Values
-
SC_REQUEST_TIMEOUT
static final int SC_REQUEST_TIMEOUTDefines the 408 status code.- See Also:
- Constant Field Values
-
SC_CONFLICT
static final int SC_CONFLICTDefines the 409 status code.- See Also:
- Constant Field Values
-
SC_GONE
static final int SC_GONEDefines the 410 status code.- See Also:
- Constant Field Values
-
SC_LENGTH_REQUIRED
static final int SC_LENGTH_REQUIREDDefines the 411 status code.- See Also:
- Constant Field Values
-
SC_PRECONDITION_FAILED
static final int SC_PRECONDITION_FAILEDDefines the 412 status code.- See Also:
- Constant Field Values
-
SC_REQUEST_ENTITY_TOO_LARGE
static final int SC_REQUEST_ENTITY_TOO_LARGEDefines the 413 status code.- See Also:
- Constant Field Values
-
SC_REQUEST_URI_TOO_LONG
static final int SC_REQUEST_URI_TOO_LONGDefines the 414 status code.- See Also:
- Constant Field Values
-
SC_UNSUPPORTED_MEDIA_TYPE
static final int SC_UNSUPPORTED_MEDIA_TYPEDefines the 415 status code.- See Also:
- Constant Field Values
-
SC_REQUESTED_RANGE_NOT_SATISFIABLE
static final int SC_REQUESTED_RANGE_NOT_SATISFIABLEDefines the 416 status code.- See Also:
- Constant Field Values
-
SC_EXPECTATION_FAILED
static final int SC_EXPECTATION_FAILEDDefines the 417 status code.- See Also:
- Constant Field Values
-
SC_INTERNAL_SERVER_ERROR
static final int SC_INTERNAL_SERVER_ERRORDefines the 500 status code.- See Also:
- Constant Field Values
-
SC_NOT_IMPLEMENTED
static final int SC_NOT_IMPLEMENTEDDefines the 501 status code.- See Also:
- Constant Field Values
-
SC_BAD_GATEWAY
static final int SC_BAD_GATEWAYDefines the 502 status code.- See Also:
- Constant Field Values
-
SC_SERVICE_UNAVAILABLE
static final int SC_SERVICE_UNAVAILABLEDefines the 503 status code.- See Also:
- Constant Field Values
-
SC_GATEWAY_TIMEOUT
static final int SC_GATEWAY_TIMEOUTDefines the 504 status code.- See Also:
- Constant Field Values
-
SC_HTTP_VERSION_NOT_SUPPORTED
static final int SC_HTTP_VERSION_NOT_SUPPORTEDDefines the 505 status code.- See Also:
- Constant Field Values
-
-
Method Details
-
addCookie
Adds the cookie.- Parameters:
cookie
- the cookie.
-
addDateHeader
void addDateHeader(java.lang.String name, long date)Add the date header.- Parameters:
name
- the name.date
- the date.
-
addHeader
void addHeader(java.lang.String name, java.lang.String value)Add the header.- Parameters:
name
- the name.value
- the value.
-
addIntHeader
void addIntHeader(java.lang.String name, int value)Add the intheader.- Parameters:
name
- the name.value
- the value.
-
containsHeader
boolean containsHeader(java.lang.String name)Contains the header.- Parameters:
name
- the name.- Returns:
- true if it contains the given header, false otherwise.
-
encodeRedirectURL
java.lang.String encodeRedirectURL(java.lang.String url)Encode the redirect URL.- Parameters:
url
- the redirect URL.- Returns:
- the encoded redirect URL.
-
encodeRedirectUrl
@Deprecated java.lang.String encodeRedirectUrl(java.lang.String url)Deprecated.Encode the redirect URL.- Parameters:
url
- the redirect URL.- Returns:
- the encoded redirect URL.
-
encodeURL
java.lang.String encodeURL(java.lang.String url)Encode the URL.- Parameters:
url
- the URL.- Returns:
- the encoded URL.
-
encodeUrl
@Deprecated java.lang.String encodeUrl(java.lang.String url)Deprecated.Encode the URL.- Parameters:
url
- the URL.- Returns:
- the encoded URL.
-
getHeader
java.lang.String getHeader(java.lang.String name)Get the header.- Parameters:
name
- the name.- Returns:
- the value, or null if not found.
-
getHeaderNames
java.util.Collection<java.lang.String> getHeaderNames()Get the header names.- Returns:
- the header names.
-
getHeaders
java.util.Collection<java.lang.String> getHeaders(java.lang.String name)Get the headers.- Parameters:
name
- the name.- Returns:
- the headers.
-
getStatus
int getStatus()Get the status.- Returns:
- the status.
-
getTrailerFields
default java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.String>> getTrailerFields()Get the supplier of trailer fields.- Returns:
- the supplier of trailer fields.
-
sendError
void sendError(int status, java.lang.String message) throws java.io.IOExceptionSend the error.- Parameters:
status
- the status code.message
- the message.- Throws:
java.io.IOException
- when an I/O error occurs.
-
sendError
void sendError(int status) throws java.io.IOExceptionSends the error.- Parameters:
status
- the status code.- Throws:
java.io.IOException
- when an I/O error occurs.
-
sendRedirect
void sendRedirect(java.lang.String location) throws java.io.IOExceptionSend a redirect.- Parameters:
location
- the location.- Throws:
java.io.IOException
- when an I/O error occurs.
-
setDateHeader
void setDateHeader(java.lang.String name, long date)Set the date header.- Parameters:
name
- the name.date
- the date.
-
setHeader
void setHeader(java.lang.String name, java.lang.String value)Set the header.- Parameters:
name
- the name.value
- the value.
-
setIntHeader
void setIntHeader(java.lang.String name, int value)Set the int header.- Parameters:
name
- the name.value
- the value.
-
setStatus
void setStatus(int status)Set the status.- Parameters:
status
- the status.
-
setStatus
@Deprecated void setStatus(int status, java.lang.String message)Deprecated.Set the status.- Parameters:
status
- the status.message
- the message.
-
setTrailerFields
default void setTrailerFields(java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.String>> supplier)Set the trailer fields supplier.- Parameters:
supplier
- the trailer fields supplier.
-