Top Description Constructors Methods
org.eclipse.jetty.ee10.servlet

public Class ServletResponseHttpWrapper

extends ServletResponseWrapper
implements HttpServletResponse
Class Inheritance
All Implemented Interfaces
jakarta.servlet.http.HttpServletResponse, jakarta.servlet.ServletResponse
Imports
java.io.IOException, java.util.Collection, jakarta.servlet.ServletResponse, .ServletResponseWrapper, jakarta.servlet.http.Cookie, .HttpServletResponse

ServletResponseHttpWrapper Wrapper to tunnel a ServletResponse via an HttpServletResponse

Constructor Summary

AccessConstructor and Description
public

Method Summary

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

Implements jakarta.servlet.http.HttpServletResponse.addCookie.

Adds the specified cookie to the response.

public void
addDateHeader(String
the name of the header to set
name
,
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(String
the name of the header
name
,
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
addIntHeader(String
the name of the header
name
,
int
the assigned integer value
value
)

Implements jakarta.servlet.http.HttpServletResponse.addIntHeader.

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

public boolean
containsHeader(String
the header name
name
)

Implements jakarta.servlet.http.HttpServletResponse.containsHeader.

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

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

Implements jakarta.servlet.http.HttpServletResponse.encodeRedirectURL.

Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged.

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.

public String
getHeader(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(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 int
getStatus()

Implements jakarta.servlet.http.HttpServletResponse.getStatus.

Gets the current status code of this response.

public void
sendError(int
the error status code
sc
,
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(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(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
setDateHeader(String
the name of the header to set
name
,
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(String
the name of the header
name
,
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
setIntHeader(String
the name of the header
name
,
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
setStatus(int
the status code
sc
)

Implements jakarta.servlet.http.HttpServletResponse.setStatus.

Sets the status code for this response.

Inherited from jakarta.servlet.ServletResponseWrapper:
flushBuffergetBufferSizegetCharacterEncodinggetContentTypegetLocalegetOutputStreamgetResponsegetWriterisCommittedisWrapperForisWrapperForresetresetBuffersetBufferSizesetCharacterEncodingsetContentLengthsetContentLengthLongsetContentTypesetLocalesetResponse

Constructor Detail

ServletResponseHttpWrapperback to summary
public ServletResponseHttpWrapper(ServletResponse response)

Method Detail

addCookieback to summary
public void addCookie(Cookie cookie)

Implements jakarta.servlet.http.HttpServletResponse.addCookie.

Doc from jakarta.servlet.http.HttpServletResponse.addCookie.

Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie.

Parameters
cookie:Cookie

the Cookie to return to the client

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

Implements jakarta.servlet.http.HttpServletResponse.addDateHeader.

Doc from jakarta.servlet.http.HttpServletResponse.addDateHeader.

Adds a response header with the given name and date-value. The date is specified in terms of milliseconds since the epoch. This method allows response headers to have multiple values.

Parameters
name:String

the name of the header to set

date:long

the additional date value

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

Implements jakarta.servlet.http.HttpServletResponse.addHeader.

Doc from jakarta.servlet.http.HttpServletResponse.addHeader.

Adds a response header with the given name and value. This method allows response headers to have multiple values.

Parameters
name:String

the name of the header

value: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)

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

Implements jakarta.servlet.http.HttpServletResponse.addIntHeader.

Doc from jakarta.servlet.http.HttpServletResponse.addIntHeader.

Adds a response header with the given name and integer value. This method allows response headers to have multiple values.

Parameters
name:String

the name of the header

value:int

the assigned integer value

Annotations
@Override
containsHeaderback to summary
public boolean containsHeader(String name)

Implements jakarta.servlet.http.HttpServletResponse.containsHeader.

Doc from jakarta.servlet.http.HttpServletResponse.containsHeader.

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

Parameters
name:String

the header name

Returns:boolean

true if the named response header has already been set; false otherwise

Annotations
@Override
encodeRedirectURLback to summary
public String encodeRedirectURL(String url)

Implements jakarta.servlet.http.HttpServletResponse.encodeRedirectURL.

Doc from jakarta.servlet.http.HttpServletResponse.encodeRedirectURL.

Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. For example, if the browser supports cookies, or session tracking is turned off, URL encoding is unnecessary. Because the rules for making this determination can differ from those used to decide whether to encode a normal link, this method is separated from the encodeURL method.

All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.

If the URL is relative, it is always relative to the current HttpServletRequest.

Parameters
url:String

the url to be encoded.

Returns:String

the encoded URL if encoding is needed; the unchanged URL otherwise.

Annotations
@Override
encodeURLback to summary
public String encodeURL(String url)

Implements jakarta.servlet.http.HttpServletResponse.encodeURL.

Doc from jakarta.servlet.http.HttpServletResponse.encodeURL.

Encodes the specified URL by including the session ID, or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. For example, if the browser supports cookies, or session tracking is turned off, URL encoding is unnecessary.

For robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.

If the URL is relative, it is always relative to the current HttpServletRequest.

Parameters
url:String

the url to be encoded.

Returns:String

the encoded URL if encoding is needed; the unchanged URL otherwise.

Annotations
@Override
getHeaderback to summary
public String getHeader(String name)

Implements jakarta.servlet.http.HttpServletResponse.getHeader.

Doc from jakarta.servlet.http.HttpServletResponse.getHeader.

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

If a response header with the given name exists and contains multiple values, the value that was added first will be returned.

This method considers only response headers set or added via setHeader, addHeader, setDateHeader, addDateHeader, setIntHeader, or addIntHeader, respectively.

Parameters
name:String

the name of the response header whose value to return

Returns:String

the value of the response header with the given name, or null if no header with the given name has been set on this response

Annotations
@Override
getHeaderNamesback to summary
public Collection<String> getHeaderNames()

Implements jakarta.servlet.http.HttpServletResponse.getHeaderNames.

Doc from jakarta.servlet.http.HttpServletResponse.getHeaderNames.

Gets the names of the headers of this response.

This method considers only response headers set or added via setHeader, addHeader, setDateHeader, addDateHeader, setIntHeader, or addIntHeader, respectively.

Any changes to the returned Collection must not affect this HttpServletResponse.

Returns:Collection<String>

a (possibly empty) Collection of the names of the headers of this response

Annotations
@Override
getHeadersback to summary
public Collection<String> getHeaders(String name)

Implements jakarta.servlet.http.HttpServletResponse.getHeaders.

Doc from jakarta.servlet.http.HttpServletResponse.getHeaders.

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

This method considers only response headers set or added via setHeader, addHeader, setDateHeader, addDateHeader, setIntHeader, or addIntHeader, respectively.

Any changes to the returned Collection must not affect this HttpServletResponse.

Parameters
name:String

the name of the response header whose values to return

Returns:Collection<String>

a (possibly empty) Collection of the values of the response header with the given name

Annotations
@Override
getStatusback to summary
public int getStatus()

Implements jakarta.servlet.http.HttpServletResponse.getStatus.

Doc from jakarta.servlet.http.HttpServletResponse.getStatus.

Gets the current status code of this response.

Returns:int

the current status code of this response

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

Implements jakarta.servlet.http.HttpServletResponse.sendError.

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

Sends an error response to the client using the specified status and clears the buffer. The server defaults to creating the response to look like an HTML-formatted server error page containing the specified message, setting the content type to "text/html". The caller is not responsible for escaping or re-encoding the message to ensure it is safe with respect to the current response encoding and content type. This aspect of safety is the responsibility of the container, as it is generating the error page containing the message. The server will preserve cookies and may clear or update any headers needed to serve the error page as a valid response.

If an error-page declaration has been made for the web application corresponding to the status code passed in, it will be served back in preference to the suggested msg parameter and the msg parameter will be ignored.

If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.

Parameters
sc:int

the error status code

msg:String

the descriptive message

Annotations
@Override
Exceptions
IOException:
If an input or output exception occurs
sendErrorback to summary
public void sendError(int sc) throws IOException

Implements jakarta.servlet.http.HttpServletResponse.sendError.

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

Sends an error response to the client using the specified status code and clears the buffer. The server will preserve cookies and may clear or update any headers needed to serve the error page as a valid response. If an error-page declaration has been made for the web application corresponding to the status code passed in, it will be served back the error page

If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.

Parameters
sc:int

the error status code

Annotations
@Override
Exceptions
IOException:
If an input or output exception occurs
sendRedirectback to summary
public void sendRedirect(String location) throws IOException

Implements jakarta.servlet.http.HttpServletResponse.sendRedirect.

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

Sends a temporary redirect response to the client using the specified redirect location URL and clears the buffer. The buffer will be replaced with the data set by this method. Calling this method sets the status code to SC_FOUND 302 (Found). This method can accept relative URLs;the servlet container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root. If the location is relative with two leading '/' the container interprets it as a network-path reference (see RFC 3986: Uniform Resource Identifier (URI): Generic Syntax, section 4.2 "Relative Reference").

If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.

Parameters
location:String

the redirect location URL

Annotations
@Override
Exceptions
IOException:
If an input or output exception occurs
setDateHeaderback to summary
public void setDateHeader(String name, long date)

Implements jakarta.servlet.http.HttpServletResponse.setDateHeader.

Doc from jakarta.servlet.http.HttpServletResponse.setDateHeader.

Sets a response header with the given name and date-value. The date is specified in terms of milliseconds since the epoch. If the header had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value.

Parameters
name:String

the name of the header to set

date:long

the assigned date value

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

Implements jakarta.servlet.http.HttpServletResponse.setHeader.

Doc from jakarta.servlet.http.HttpServletResponse.setHeader.

Sets a response header with the given name and value. If the header had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value.

Parameters
name:String

the name of the header

value:String

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

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

Implements jakarta.servlet.http.HttpServletResponse.setIntHeader.

Doc from jakarta.servlet.http.HttpServletResponse.setIntHeader.

Sets a response header with the given name and integer value. If the header had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value.

Parameters
name:String

the name of the header

value:int

the assigned integer value

Annotations
@Override
setStatusback to summary
public void setStatus(int sc)

Implements jakarta.servlet.http.HttpServletResponse.setStatus.

Doc from jakarta.servlet.http.HttpServletResponse.setStatus.

Sets the status code for this response.

This method is used to set the return status code when there is no error (for example, for the SC_OK or SC_MOVED_TEMPORARILY status codes).

If this method is used to set an error code, then the container's error page mechanism will not be triggered. If there is an error and the caller wishes to invoke an error page defined in the web application, then sendError must be used instead.

This method preserves any cookies and other response headers.

Valid status codes are those in the 2XX, 3XX, 4XX, and 5XX ranges. Other status codes are treated as container specific.

Parameters
sc:int

the status code

Annotations
@Override