Top Description Inners Fields Constructors Methods
io.undertow.servlet.spec

public final Class HttpServletResponseImpl

extends Object
implements HttpServletResponse
Class Inheritance
All Implemented Interfaces
jakarta.servlet.http.HttpServletResponse, jakarta.servlet.ServletResponse
Imports
java.io.IOException, .PrintWriter, .UnsupportedEncodingException, java.net.MalformedURLException, .URL, java.nio.charset.StandardCharsets, java.util.ArrayList, .Collection, .Collections, .Date, .HashSet, .Locale, .Map, .Set, java.util.function.Supplier, jakarta.servlet.ServletException, .ServletOutputStream, .SessionTrackingMode, jakarta.servlet.http.Cookie, .HttpServletResponse, .HttpSession, io.undertow.UndertowLogger, io.undertow.server.HttpServerExchange, io.undertow.server.protocol.http.HttpAttachments, io.undertow.servlet.UndertowServletMessages, io.undertow.servlet.core.DefaultCharsetMapping, io.undertow.servlet.handlers.ServletRequestContext, io.undertow.util.CanonicalPathUtils, .DateUtils, .HeaderMap, .HeaderValues, .Headers, .HttpString, .Protocols, .RedirectBuilder, .StatusCodes, org.xnio.Bits

Implementation of HttpServletResponse.
Authors
Stuart Douglas, Richard Opalka, Flavia Rainone

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
private Integer
private String
private static final int
private static final int
private long
private String
private final HttpServerExchange
private int
private static final int
private static final int
private Locale
private final ServletContextImpl
private static final int
private HttpServletResponseImpl.ResponseState
private volatile ServletContextImpl
private ServletOutputStreamImpl
private Supplier<Map<String, String>>
private static final int
private PrintWriter

Constructor Summary

AccessConstructor and Description
public
HttpServletResponseImpl(final HttpServerExchange exchange, final ServletContextImpl servletContext)

Method Summary

Modifier and TypeMethod and Description
public void
addCookie(final Cookie
the Cookie to return to the client
newCookie
)

Implements jakarta.servlet.http.HttpServletResponse.addCookie.

Adds the specified cookie to the response.

public void
addDateHeader(final String
the name of the header to set
name
,
final long
the additional date value
date
)

Implements jakarta.servlet.http.HttpServletResponse.addDateHeader.

Adds a response header with the given name and date-value.

public void
addHeader(final String
the name of the header
name
,
final String
the additional header value If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)
value
)

Implements jakarta.servlet.http.HttpServletResponse.addHeader.

Adds a response header with the given name and value.

public void
addHeader(final HttpString name, final String value)

public void
addIntHeader(final String
the name of the header
name
,
final int
the assigned integer value
value
)

Implements jakarta.servlet.http.HttpServletResponse.addIntHeader.

Adds a response header with the given name and integer value.

public void
public boolean
containsHeader(final String
the header name
name
)

Implements jakarta.servlet.http.HttpServletResponse.containsHeader.

Returns a boolean indicating whether the named response header has already been set.

private void
public void
doErrorDispatch(int sc, String error)

private boolean
public String
encodeRedirectURL(String
URL to be encoded
url
)

Implements jakarta.servlet.http.HttpServletResponse.encodeRedirectURL.

Encode the session identifier associated with this response into the specified redirect URL, if necessary.

public String
encodeURL(String
the url to be encoded.
url
)

Implements jakarta.servlet.http.HttpServletResponse.encodeURL.

Encodes the specified URL by including the session ID, or, if encoding is not needed, returns the URL unchanged.

private static String
public void
flushBuffer()

Implements jakarta.servlet.ServletResponse.flushBuffer.

Forces any content in the buffer to be written to the client.

public void
public int
getBufferSize()

Implements jakarta.servlet.ServletResponse.getBufferSize.

Returns the actual buffer size used for the response.

public String
getCharacterEncoding()

Implements jakarta.servlet.ServletResponse.getCharacterEncoding.

Returns the name of the character encoding (MIME charset) used for the body sent in this response.

public long
public String
getContentType()

Implements jakarta.servlet.ServletResponse.getContentType.

Returns the content type used for the MIME body sent in this response.

public HttpServerExchange
public String
getHeader(final String
the name of the response header whose value to return
name
)

Implements jakarta.servlet.http.HttpServletResponse.getHeader.

Gets the value of the response header with the given name.

public Collection<String>
getHeaderNames()

Implements jakarta.servlet.http.HttpServletResponse.getHeaderNames.

Gets the names of the headers of this response.

public Collection<String>
getHeaders(final String
the name of the response header whose values to return
name
)

Implements jakarta.servlet.http.HttpServletResponse.getHeaders.

Gets the values of the response header with the given name.

public Locale
getLocale()

Implements jakarta.servlet.ServletResponse.getLocale.

Returns the locale specified for this response using the setLocale method.

public ServletOutputStream
getOutputStream()

Implements jakarta.servlet.ServletResponse.getOutputStream.

Returns a ServletOutputStream suitable for writing binary data in the response.

public ServletContextImpl
public int
getStatus()

Implements jakarta.servlet.http.HttpServletResponse.getStatus.

Gets the current status code of this response.

public Supplier<Map<String, String>>
getTrailerFields()

Overrides default jakarta.servlet.http.HttpServletResponse.getTrailerFields.

Gets the supplier of trailer headers.

public PrintWriter
getWriter()

Implements jakarta.servlet.ServletResponse.getWriter.

Returns a PrintWriter object that can send character text to the client.

private boolean
hasScheme(String uri)

Determine if a URI string has a scheme component.

public boolean
isCommitted()

Implements jakarta.servlet.ServletResponse.isCommitted.

Returns a boolean indicating if the response has been committed.

private boolean
isEncodeable(final String
Absolute URL to be validated
location
)

Return true if the specified URL should be encoded with a session identifier.

pack-priv boolean
public boolean
public boolean
public void
reset()

Implements jakarta.servlet.ServletResponse.reset.

Clears any data that exists in the buffer as well as the status code, headers.

public void
resetBuffer()

Implements jakarta.servlet.ServletResponse.resetBuffer.

Clears the content of the underlying buffer in the response without clearing headers or status code.

public void
private boolean
public void
sendError(final int
the error status code
sc
,
final String
the descriptive message
msg
)

Implements jakarta.servlet.http.HttpServletResponse.sendError.

Sends an error response to the client using the specified status and clears the buffer.

public void
sendError(final int
the error status code
sc
)

Implements jakarta.servlet.http.HttpServletResponse.sendError.

Sends an error response to the client using the specified status code and clears the buffer.

public void
sendRedirect(final String
the redirect location URL
location
)

Implements jakarta.servlet.http.HttpServletResponse.sendRedirect.

Sends a temporary redirect response to the client using the specified redirect location URL and clears the buffer.

public void
setBufferSize(final int
the preferred buffer size
size
)

Implements jakarta.servlet.ServletResponse.setBufferSize.

Sets the preferred buffer size for the body of the response.

public void
setCharacterEncoding(final String
a String specifying only the character set defined by IANA Character Sets (http://www.iana.org/assignments/character-sets) or null
charset
)

Implements jakarta.servlet.ServletResponse.setCharacterEncoding.

Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.

pack-priv void
setContentFullyWritten()

Marks this response as closed for writing extra bytes, including the addition of headers.

public void
setContentLength(final int
an integer specifying the length of the content being returned to the client; sets the Content-Length header
len
)

Implements jakarta.servlet.ServletResponse.setContentLength.

Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header.

public void
setContentLengthLong(final long
a long specifying the length of the content being returned to the client; sets the Content-Length header
len
)

Implements jakarta.servlet.ServletResponse.setContentLengthLong.

Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header.

public void
setContentType(final String
a String specifying the MIME type of the content or null
type
)

Implements jakarta.servlet.ServletResponse.setContentType.

Sets the content type of the response being sent to the client, if the response has not been committed yet.

public void
setDateHeader(final String
the name of the header to set
name
,
final long
the assigned date value
date
)

Implements jakarta.servlet.http.HttpServletResponse.setDateHeader.

Sets a response header with the given name and date-value.

public void
setHeader(final String
the name of the header
name
,
final String
the header value If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)
value
)

Implements jakarta.servlet.http.HttpServletResponse.setHeader.

Sets a response header with the given name and value.

public void
setHeader(final HttpString name, final String value)

pack-priv void
setIgnoredFlushPerformed(boolean ignoredFlushPerformed)

public void
setInsideInclude(final boolean insideInclude)

public void
setIntHeader(final String
the name of the header
name
,
final int
the assigned integer value
value
)

Implements jakarta.servlet.http.HttpServletResponse.setIntHeader.

Sets a response header with the given name and integer value.

public void
setLocale(final Locale
the locale of the response or {code @null}
loc
)

Implements jakarta.servlet.ServletResponse.setLocale.

Sets the locale of the response, if the response has not been committed yet.

public void
setServletContext(final ServletContextImpl servletContext)

public void
setStatus(final int
the status code
sc
)

Implements jakarta.servlet.http.HttpServletResponse.setStatus.

Sets the status code for this response.

public void
setTrailerFields(Supplier<Map<String, String>>
the supplier of trailer headers
supplier
)

Overrides default jakarta.servlet.http.HttpServletResponse.setTrailerFields.

Sets the supplier of trailer headers.

private String
toAbsolute(String
URL to be (possibly) converted and then returned
location
)

Convert (if necessary) and return the absolute URL that represents the resource referenced by this possibly relative URL.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait