Top Description Fields Constructors Methods
org.glassfish.grizzly.servlet

public Class DispatchedHttpServletResponse

extends HttpServletResponseWrapper
Class Inheritance
Imports
java.io.IOException, java.util.Locale, jakarta.servlet.http.Cookie, .HttpServletResponse, .HttpServletResponseWrapper

Wrapper around a jakarta.servlet.http.HttpServletResponse that transforms an application response object (which might be the original one passed to a servlet.
Author
Bongjae Chang

Field Summary

Modifier and TypeField and Description
private boolean
included

Is this wrapped response the subject of an include() call?

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addCookie(Cookie cookie)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.addCookie.

Implements jakarta.servlet.http.HttpServletResponse.addCookie.

The default behavior of this method is to call addCookie(Cookie cookie) on the wrapped response object.

public void
addDateHeader(String name, long date)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.addDateHeader.

Implements jakarta.servlet.http.HttpServletResponse.addDateHeader.

The default behavior of this method is to call addDateHeader(String name, long date) on the wrapped response object.

public void
addHeader(String name, String value)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.addHeader.

Implements jakarta.servlet.http.HttpServletResponse.addHeader.

The default behavior of this method is to return addHeader(String name, String value) on the wrapped response object.

public void
addIntHeader(String name, int value)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.addIntHeader.

Implements jakarta.servlet.http.HttpServletResponse.addIntHeader.

The default behavior of this method is to call addIntHeader(String name, int value) on the wrapped response object.

public void
reset()

Overrides jakarta.servlet.ServletResponseWrapper.reset.

Implements jakarta.servlet.ServletResponse.reset.

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

public void
sendError(int sc, String msg)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.sendError.

Implements jakarta.servlet.http.HttpServletResponse.sendError.

The default behavior of this method is to call sendError(int sc, String msg) on the wrapped response object.

public void
sendError(int sc)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.sendError.

Implements jakarta.servlet.http.HttpServletResponse.sendError.

The default behavior of this method is to call sendError(int sc) on the wrapped response object.

public void
sendRedirect(String location)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.sendRedirect.

Overrides default jakarta.servlet.http.HttpServletResponse.sendRedirect.

The default behavior of this method is to return sendRedirect(String location) on the wrapped response object.

public void
setBufferSize(int size)

Overrides jakarta.servlet.ServletResponseWrapper.setBufferSize.

Implements jakarta.servlet.ServletResponse.setBufferSize.

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

public void
setCharacterEncoding(String charEnc)

Overrides jakarta.servlet.ServletResponseWrapper.setCharacterEncoding.

Implements jakarta.servlet.ServletResponse.setCharacterEncoding.

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

public void
setContentLength(int len)

Overrides jakarta.servlet.ServletResponseWrapper.setContentLength.

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
setContentType(String type)

Overrides jakarta.servlet.ServletResponseWrapper.setContentType.

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(String name, long date)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.setDateHeader.

Implements jakarta.servlet.http.HttpServletResponse.setDateHeader.

The default behavior of this method is to call setDateHeader(String name, long date) on the wrapped response object.

public void
setHeader(String name, String value)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.setHeader.

Implements jakarta.servlet.http.HttpServletResponse.setHeader.

The default behavior of this method is to return setHeader(String name, String value) on the wrapped response object.

public void
setIntHeader(String name, int value)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.setIntHeader.

Implements jakarta.servlet.http.HttpServletResponse.setIntHeader.

The default behavior of this method is to call setIntHeader(String name, int value) on the wrapped response object.

public void
setLocale(Locale loc)

Overrides jakarta.servlet.ServletResponseWrapper.setLocale.

Implements jakarta.servlet.ServletResponse.setLocale.

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

private void
setResponse(HttpServletResponse
The new wrapped response
response
)

Set the response that we are wrapping.

public void
setStatus(int sc)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.setStatus.

Implements jakarta.servlet.http.HttpServletResponse.setStatus.

The default behavior of this method is to call setStatus(int sc) on the wrapped response object.

Inherited from jakarta.servlet.http.HttpServletResponseWrapper:
containsHeaderencodeRedirectURLencodeURLgetHeadergetHeaderNamesgetHeadersgetStatusgetTrailerFieldssendRedirectsendRedirectsendRedirectsetTrailerFields

Field Detail

includedback to summary
private boolean included

Is this wrapped response the subject of an include() call?

Constructor Detail

DispatchedHttpServletResponseback to summary
public DispatchedHttpServletResponse(HttpServletResponse response, boolean included)

Method Detail

addCookieback to summary
public void addCookie(Cookie cookie)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.addCookie.

Implements jakarta.servlet.http.HttpServletResponse.addCookie.

Doc from jakarta.servlet.http.HttpServletResponseWrapper.addCookie.

The default behavior of this method is to call addCookie(Cookie cookie) on the wrapped response object.

Annotations
@Override
addDateHeaderback to summary
public void addDateHeader(String name, long date)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.addDateHeader.

Implements jakarta.servlet.http.HttpServletResponse.addDateHeader.

Doc from jakarta.servlet.http.HttpServletResponseWrapper.addDateHeader.

The default behavior of this method is to call addDateHeader(String name, long date) on the wrapped response object.

Annotations
@Override
addHeaderback to summary
public void addHeader(String name, String value)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.addHeader.

Implements jakarta.servlet.http.HttpServletResponse.addHeader.

Doc from jakarta.servlet.http.HttpServletResponseWrapper.addHeader.

The default behavior of this method is to return addHeader(String name, String value) on the wrapped response object.

Annotations
@Override
addIntHeaderback to summary
public void addIntHeader(String name, int value)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.addIntHeader.

Implements jakarta.servlet.http.HttpServletResponse.addIntHeader.

Doc from jakarta.servlet.http.HttpServletResponseWrapper.addIntHeader.

The default behavior of this method is to call addIntHeader(String name, int value) on the wrapped response object.

Annotations
@Override
resetback to summary
public void reset()

Overrides jakarta.servlet.ServletResponseWrapper.reset.

Implements jakarta.servlet.ServletResponse.reset.

Doc from jakarta.servlet.ServletResponse.reset.

Clears any data that exists in the buffer as well as the status code, headers. The state of calling getWriter or getOutputStream is also cleared. It is legal, for instance, to call getWriter, reset and then getOutputStream. If getWriter or getOutputStream have been called before this method, then the corrresponding returned Writer or OutputStream will be staled and the behavior of using the stale object is undefined. If the response has been committed, this method throws an IllegalStateException.

Annotations
@Override
sendErrorback to summary
public void sendError(int sc, String msg) throws IOException

Overrides jakarta.servlet.http.HttpServletResponseWrapper.sendError.

Implements jakarta.servlet.http.HttpServletResponse.sendError.

Doc from jakarta.servlet.http.HttpServletResponseWrapper.sendError.

The default behavior of this method is to call sendError(int sc, String msg) on the wrapped response object.

Annotations
@Override
Exceptions
IOException:

Doc from jakarta.servlet.http.HttpServletResponse.sendError.

If an input or output exception occurs

sendErrorback to summary
public void sendError(int sc) throws IOException

Overrides jakarta.servlet.http.HttpServletResponseWrapper.sendError.

Implements jakarta.servlet.http.HttpServletResponse.sendError.

Doc from jakarta.servlet.http.HttpServletResponseWrapper.sendError.

The default behavior of this method is to call sendError(int sc) on the wrapped response object.

Annotations
@Override
Exceptions
IOException:

Doc from jakarta.servlet.http.HttpServletResponse.sendError.

If an input or output exception occurs

sendRedirectback to summary
public void sendRedirect(String location) throws IOException

Overrides jakarta.servlet.http.HttpServletResponseWrapper.sendRedirect.

Overrides default jakarta.servlet.http.HttpServletResponse.sendRedirect.

Doc from jakarta.servlet.http.HttpServletResponseWrapper.sendRedirect.

The default behavior of this method is to return sendRedirect(String location) on the wrapped response object.

Annotations
@Override
Exceptions
IOException:

Doc from jakarta.servlet.http.HttpServletResponse.sendRedirect.

If an input or output exception occurs

setBufferSizeback to summary
public void setBufferSize(int size)

Overrides jakarta.servlet.ServletResponseWrapper.setBufferSize.

Implements jakarta.servlet.ServletResponse.setBufferSize.

Doc from jakarta.servlet.ServletResponse.setBufferSize.

Sets the preferred buffer size for the body of the response. The servlet container will use a buffer at least as large as the size requested. The actual buffer size used can be found using getBufferSize.

A larger buffer allows more content to be written before anything is actually sent, thus providing the servlet with more time to set appropriate status codes and headers. A smaller buffer decreases server memory load and allows the client to start receiving data more quickly.

This method must be called before any response body content is written; if content has been written or the response object has been committed, this method throws an IllegalStateException.

Annotations
@Override
setCharacterEncodingback to summary
public void setCharacterEncoding(String charEnc)

Overrides jakarta.servlet.ServletResponseWrapper.setCharacterEncoding.

Implements jakarta.servlet.ServletResponse.setCharacterEncoding.

Doc from jakarta.servlet.ServletResponse.setCharacterEncoding.

Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8. If the response character encoding has already been set by ServletContext#setResponseCharacterEncoding, the deployment descriptor, or using the setCharacterEncoding(Charset), setContentType or setLocale methods, the value set in this method overrides all of those values. Calling setContentType with the String of text/html and calling this method with the String of UTF-8 is equivalent to calling setContentType with the String of text/html; charset=UTF-8.

This method can be called repeatedly to change the character encoding. This method has no effect if it is called after getWriter has been called or after the response has been committed.

If calling this method has an effect (as per the previous paragraph), calling this method with null clears any character encoding set via a previous call to this method, setCharacterEncoding(Charset), setContentType or setLocale but does not affect any default character encoding configured via ServletContext#setResponseCharacterEncoding or the deployment descriptor.

If this method is called with an invalid or unrecognised character encoding, then a subsequent call to getWriter() will throw a UnsupportedEncodingException. Content for an unknown encoding can be sent with the ServletOutputStream returned from getOutputStream().

Containers may choose to log calls to this method that use an invalid or unrecognised character encoding.

Containers must communicate the character encoding used for the servlet response's writer to the client if the protocol provides a way for doing so. In the case of HTTP, the character encoding is communicated as part of the Content-Type header for text media types. Note that the character encoding cannot be communicated via HTTP headers if the servlet does not specify a content type; however, it is still used to encode text written via the servlet response's writer.

Annotations
@Override
setContentLengthback to summary
public void setContentLength(int len)

Overrides jakarta.servlet.ServletResponseWrapper.setContentLength.

Implements jakarta.servlet.ServletResponse.setContentLength.

Doc from 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.

This method may be called repeatedly to change the content length. This method has no effect if called after the response has been committed.

Annotations
@Override
setContentTypeback to summary
public void setContentType(String type)

Overrides jakarta.servlet.ServletResponseWrapper.setContentType.

Implements jakarta.servlet.ServletResponse.setContentType.

Doc from jakarta.servlet.ServletResponse.setContentType.

Sets the content type of the response being sent to the client, if the response has not been committed yet. The given content type may include a character encoding specification, for example, text/html;charset=UTF-8. The response's character encoding is only set from the given content type if this method is called before getWriter() is called.

This method may be called repeatedly to change content type and character encoding. This method has no effect if called after the response has been committed. It does not set the response's character encoding if it is called after getWriter has been called or after the response has been committed.

If calling this method has an effect (as per the previous paragraph), calling this method with null clears any content type set via a previous call to this method and clears any character encoding set via a previous call to this method, setCharacterEncoding(String), setCharacterEncoding(Charset) or setLocale but does not affect any default character encoding configured via ServletContext#setResponseCharacterEncoding or the deployment descriptor.

If this method is called with an invalid or unrecognised character encoding, then a subsequent call to getWriter() will throw a UnsupportedEncodingException. Content for an unknown encoding can be sent with the ServletOutputStream returned from getOutputStream().

Containers may choose to log calls to this method that use an invalid or unrecognised character encoding.

Containers must communicate the content type and the character encoding used for the servlet response's writer to the client if the protocol provides a way for doing so. In the case of HTTP, the Content-Type header is used.

Annotations
@Override
setDateHeaderback to summary
public void setDateHeader(String name, long date)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.setDateHeader.

Implements jakarta.servlet.http.HttpServletResponse.setDateHeader.

Doc from jakarta.servlet.http.HttpServletResponseWrapper.setDateHeader.

The default behavior of this method is to call setDateHeader(String name, long date) on the wrapped response object.

Annotations
@Override
setHeaderback to summary
public void setHeader(String name, String value)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.setHeader.

Implements jakarta.servlet.http.HttpServletResponse.setHeader.

Doc from jakarta.servlet.http.HttpServletResponseWrapper.setHeader.

The default behavior of this method is to return setHeader(String name, String value) on the wrapped response object.

Annotations
@Override
setIntHeaderback to summary
public void setIntHeader(String name, int value)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.setIntHeader.

Implements jakarta.servlet.http.HttpServletResponse.setIntHeader.

Doc from jakarta.servlet.http.HttpServletResponseWrapper.setIntHeader.

The default behavior of this method is to call setIntHeader(String name, int value) on the wrapped response object.

Annotations
@Override
setLocaleback to summary
public void setLocale(Locale loc)

Overrides jakarta.servlet.ServletResponseWrapper.setLocale.

Implements jakarta.servlet.ServletResponse.setLocale.

Doc from jakarta.servlet.ServletResponse.setLocale.

Sets the locale of the response, if the response has not been committed yet. It also sets the response's character encoding appropriately for the locale, if the character encoding has not been explicitly set using setContentType, setCharacterEncoding(String) or setCharacterEncoding(Charset), getWriter hasn't been called yet, and the response hasn't been committed yet. If the deployment descriptor contains a locale-encoding-mapping-list element, and that element provides a mapping for the given locale, that mapping is used. Otherwise, the mapping from locale to character encoding is container dependent.

This method may be called repeatedly to change locale and character encoding. The method has no effect if called after the response has been committed. It does not set the response's character encoding if it is called after setContentType has been called with a charset specification, after setCharacterEncoding(String) has been called, after setCharacterEncoding(Charset) has been called, after getWriter has been called, or after the response has been committed.

If calling this method has an effect on the locale (as per the previous paragraph), calling this method with null clears any locale set via a previous call to this method. If calling this method has an effect on the character encoding, calling this method with null clears the previously set character encoding.

Containers must communicate the locale and the character encoding used for the servlet response's writer to the client if the protocol provides a way for doing so. In the case of HTTP, the locale is communicated via the Content-Language header, the character encoding as part of the Content-Type header for text media types. Note that the character encoding cannot be communicated via HTTP headers if the servlet does not specify a content type; however, it is still used to encode text written via the servlet response's writer.

Annotations
@Override
setResponseback to summary
private void setResponse(HttpServletResponse response)

Set the response that we are wrapping.

Parameters
response:HttpServletResponse

The new wrapped response

setStatusback to summary
public void setStatus(int sc)

Overrides jakarta.servlet.http.HttpServletResponseWrapper.setStatus.

Implements jakarta.servlet.http.HttpServletResponse.setStatus.

Doc from jakarta.servlet.http.HttpServletResponseWrapper.setStatus.

The default behavior of this method is to call setStatus(int sc) on the wrapped response object.

Annotations
@Override