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

public Class ServletContextResponse

extends ContextResponse
implements ServletResponseInfo
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo
Imports
java.io.IOException, java.nio.ByteBuffer, java.util.Locale, .Map, java.util.function.Supplier, jakarta.servlet.ServletContext, .ServletResponse, .ServletResponseWrapper, jakarta.servlet.http.HttpServletResponse, .HttpSession, org.eclipse.jetty.http.HttpCookie, .HttpField, .HttpFields, .HttpGenerator, .HttpHeader, .HttpHeaderValue, .HttpStatus, .HttpVersion, .MimeTypes, org.eclipse.jetty.io.RuntimeIOException, org.eclipse.jetty.server.Response, org.eclipse.jetty.server.handler.ContextResponse, org.eclipse.jetty.session.ManagedSession, org.eclipse.jetty.util.BufferUtil, .Callback

A core response wrapper that carries the servlet related response state, which may be used directly by the associated ServletApiResponse. Non servlet related state, is used indirectly via ServletChannel#getResponse() which may be a wrapper of this response.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static enum
private class
ServletContextResponse.HttpFieldsWrapper

Wrapper of the response HttpFields to allow specific values to be intercepted.

protected static enum

Field Summary

Modifier and TypeField and Description
private String
private long
private String
private ServletContextResponse.EncodingFrom
private final HttpFields.Mutable.Wrapper
private Locale
private MimeTypes.Type
private ServletContextResponse.OutputType
private final ServletApiResponse
private final ServletChannel
private Supplier<Map<String, String>>
private ResponseWriter
private long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
public String
public String
pack-priv long

Returns:

the number of bytes written via this class write(boolean, ByteBuffer, Callback) method.
getContentBytesWritten
()

Returns the number of bytes written via this class write(boolean, ByteBuffer, Callback) method.

public long
public String
public ServletContextResponse.EncodingFrom
public HttpFields.Mutable
public HttpOutput
public Locale
protected MimeTypes.Type
public ServletContextResponse.OutputType
public String

Returns:

the raw character encoding
getRawCharacterEncoding
()

Get the raw value of the Character Encoding field.

public Response
public ServletApiResponse
protected ServletContextRequest
public static ServletContextResponse
public ServletChannelState
public Supplier<Map<String, String>>
public ResponseWriter
public void
public boolean
isAllContentWritten(long written)

public boolean
isContentIncomplete(long written)

public boolean
public boolean
public boolean
protected ServletApiResponse
public void
reset()

Overrides org.eclipse.jetty.server.Response.Wrapper.reset.

Implements org.eclipse.jetty.server.Response.reset.

Resets this response, clearing the HTTP status code, HTTP headers and HTTP trailers.

public void
public void
public void
setCharacterEncoding(String
the character encoding
encoding
,
ServletContextResponse.EncodingFrom
where encoding came from
from
)

Implements org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo.setCharacterEncoding.

Update the Content-Type, MimeType, and headers from the provided Character Encoding and EncodingFrom.

public void
public void
setContentLength(long len)

public void
public void
public void
public void
public void
write(boolean
whether the ByteBuffer is the last to write
last
,
ByteBuffer
the ByteBuffer to write
content
,
Callback
the callback to notify when the write operation is complete
callback
)

Overrides org.eclipse.jetty.server.handler.ContextResponse.write.

Implements org.eclipse.jetty.server.Response.write.

Writes the given ByteBuffer, notifying the Callback when the write is complete.

Field Detail

_characterEncodingback to summary
private String _characterEncoding
_contentLengthback to summary
private long _contentLength
_contentTypeback to summary
private String _contentType
_encodingFromback to summary
private ServletContextResponse.EncodingFrom _encodingFrom
_headersback to summary
private final HttpFields.Mutable.Wrapper _headers
_localeback to summary
private Locale _locale
_mimeTypeback to summary
private MimeTypes.Type _mimeType
_outputTypeback to summary
private ServletContextResponse.OutputType _outputType
_servletApiResponseback to summary
private final ServletApiResponse _servletApiResponse
_servletChannelback to summary
private final ServletChannel _servletChannel
_trailersback to summary
private Supplier<Map<String, String>> _trailers
_writerback to summary
private ResponseWriter _writer
_writtenback to summary
private long _written

Constructor Detail

ServletContextResponseback to summary
public ServletContextResponse(ServletChannel servletChannel, ServletContextRequest request, Response response)

Method Detail

closeOutputback to summary
public void closeOutput() throws IOException
completeOutputback to summary
public void completeOutput(Callback callback)
getCharacterEncodingback to summary
public String getCharacterEncoding()

Implements org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo.getCharacterEncoding.

Annotations
@Override
getCharacterEncodingback to summary
public String getCharacterEncoding(boolean setContentType)

Implements org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo.getCharacterEncoding.

Annotations
@Override
getContentBytesWrittenback to summary
pack-priv long getContentBytesWritten()

Returns the number of bytes written via this class write(boolean, ByteBuffer, Callback) method.

The number of bytes written to the network may be different.

Returns:long

the number of bytes written via this class write(boolean, ByteBuffer, Callback) method.

getContentLengthback to summary
public long getContentLength()
getContentTypeback to summary
public String getContentType()

Implements org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo.getContentType.

Annotations
@Override
getEncodingFromback to summary
public ServletContextResponse.EncodingFrom getEncodingFrom()

Implements org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo.getEncodingFrom.

Annotations
@Override
getHeadersback to summary
public HttpFields.Mutable getHeaders()

Overrides org.eclipse.jetty.server.Response.Wrapper.getHeaders.

Implements org.eclipse.jetty.server.Response.getHeaders.

Returns:HttpFields.Mutable

Doc from org.eclipse.jetty.server.Response.getHeaders.

the response HTTP headers

Annotations
@Override
getHttpOutputback to summary
public HttpOutput getHttpOutput()
getLocaleback to summary
public Locale getLocale()

Implements org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo.getLocale.

Annotations
@Override
getMimeTypeback to summary
protected MimeTypes.Type getMimeType()
getOutputTypeback to summary
public ServletContextResponse.OutputType getOutputType()

Implements org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo.getOutputType.

Annotations
@Override
getRawCharacterEncodingback to summary
public String getRawCharacterEncoding()

Get the raw value of the Character Encoding field.

This is only the value as set, not from any other discovered source (eg: mimetypes, Content-Type, ServletContext, etc)

Returns:String

the raw character encoding

getResponseback to summary
public Response getResponse()

Implements org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo.getResponse.

Annotations
@Override
getServletApiResponseback to summary
public ServletApiResponse getServletApiResponse()
getServletContextRequestback to summary
protected ServletContextRequest getServletContextRequest()
getServletContextResponseback to summary
public static ServletContextResponse getServletContextResponse(ServletResponse response)
getServletRequestStateback to summary
public ServletChannelState getServletRequestState()
getTrailersback to summary
public Supplier<Map<String, String>> getTrailers()

Implements org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo.getTrailers.

Annotations
@Override
getWriterback to summary
public ResponseWriter getWriter()

Implements org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo.getWriter.

Annotations
@Override
includedback to summary
public void included()
isAllContentWrittenback to summary
public boolean isAllContentWritten(long written)
isContentIncompleteback to summary
public boolean isContentIncomplete(long written)
isStreamingback to summary
public boolean isStreaming()
isWritingback to summary
public boolean isWriting()

Implements org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo.isWriting.

Annotations
@Override
isWritingOrStreamingback to summary
public boolean isWritingOrStreaming()
newServletApiResponseback to summary
protected ServletApiResponse newServletApiResponse()
resetback to summary
public void reset()

Overrides org.eclipse.jetty.server.Response.Wrapper.reset.

Implements org.eclipse.jetty.server.Response.reset.

Doc from org.eclipse.jetty.server.Response.reset.

Resets this response, clearing the HTTP status code, HTTP headers and HTTP trailers.

Annotations
@Override
resetContentback to summary
public void resetContent()
resetForForwardback to summary
public void resetForForward()
setCharacterEncodingback to summary
public void setCharacterEncoding(String encoding, ServletContextResponse.EncodingFrom from)

Implements org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo.setCharacterEncoding.

Update the Content-Type, MimeType, and headers from the provided Character Encoding and EncodingFrom.

Parameters
encoding:String

the character encoding

from:ServletContextResponse.EncodingFrom

where encoding came from

Annotations
@Override
setContentLengthback to summary
public void setContentLength(int len)
setContentLengthback to summary
public void setContentLength(long len)
setLocaleback to summary
public void setLocale(Locale locale)

Implements org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo.setLocale.

Annotations
@Override
setOutputTypeback to summary
public void setOutputType(ServletContextResponse.OutputType outputType)

Implements org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo.setOutputType.

Annotations
@Override
setTrailersback to summary
public void setTrailers(Supplier<Map<String, String>> trailers)

Implements org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo.setTrailers.

Annotations
@Override
setWriterback to summary
public void setWriter(ResponseWriter writer)

Implements org.eclipse.jetty.ee10.servlet.ServletContextHandler.ServletResponseInfo.setWriter.

Annotations
@Override
writeback to summary
public void write(boolean last, ByteBuffer content, Callback callback)

Overrides org.eclipse.jetty.server.handler.ContextResponse.write.

Implements org.eclipse.jetty.server.Response.write.

Doc from org.eclipse.jetty.server.Response.write.

Writes the given ByteBuffer, notifying the Callback when the write is complete.

Implementations guarantee that calls to this method are safely reentrant so that stack overflows are avoided in the case of mutual recursion between the execution of the Callback and a call to this method.

The invocation of the passed Callback is serialized with previous calls of this method, so that it is not invoked until any invocation of the callback of a previous call to this method has returned.

Thus a Callback should not block waiting for a callback of a future call to this method.

Parameters
last:boolean

whether the ByteBuffer is the last to write

content:ByteBuffer

the ByteBuffer to write

callback:Callback

the callback to notify when the write operation is complete

Annotations
@Override
org.eclipse.jetty.ee10.servlet back to summary

protected final Enum ServletContextResponse.EncodingFrom

extends Enum<ServletContextResponse.EncodingFrom>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final ServletContextResponse.EncodingFrom
DEFAULT

Using the default character encoding from the context otherwise iso-8859-1.

public static final ServletContextResponse.EncodingFrom
INFERRED

Character encoding was inferred from the Content-Type and will be added as a parameter to the Content-Type.

public static final ServletContextResponse.EncodingFrom
NOT_SET

Character encoding was not set, or the encoding was cleared with setCharacterEncoding(null).

public static final ServletContextResponse.EncodingFrom
SET_CHARACTER_ENCODING

The character encoding has been explicitly set using HttpServletResponse#setCharacterEncoding(String).

public static final ServletContextResponse.EncodingFrom
SET_CONTENT_TYPE

The character encoding has been explicitly set using the Content-Type charset parameter with HttpServletResponse#setContentType(String).

public static final ServletContextResponse.EncodingFrom
SET_LOCALE

The default character encoding of the locale was used after a call to HttpServletResponse#setLocale(Locale).

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ServletContextResponse.EncodingFrom
public static ServletContextResponse.EncodingFrom[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

DEFAULTback to summary
public static final ServletContextResponse.EncodingFrom DEFAULT

Using the default character encoding from the context otherwise iso-8859-1.

INFERREDback to summary
public static final ServletContextResponse.EncodingFrom INFERRED

Character encoding was inferred from the Content-Type and will be added as a parameter to the Content-Type.

NOT_SETback to summary
public static final ServletContextResponse.EncodingFrom NOT_SET

Character encoding was not set, or the encoding was cleared with setCharacterEncoding(null).

SET_CHARACTER_ENCODINGback to summary
public static final ServletContextResponse.EncodingFrom SET_CHARACTER_ENCODING

The character encoding has been explicitly set using HttpServletResponse#setCharacterEncoding(String).

SET_CONTENT_TYPEback to summary
public static final ServletContextResponse.EncodingFrom SET_CONTENT_TYPE

The character encoding has been explicitly set using the Content-Type charset parameter with HttpServletResponse#setContentType(String).

SET_LOCALEback to summary
public static final ServletContextResponse.EncodingFrom SET_LOCALE

The default character encoding of the locale was used after a call to HttpServletResponse#setLocale(Locale).

Constructor Detail

EncodingFromback to summary
private EncodingFrom()

Method Detail

valueOfback to summary
public static ServletContextResponse.EncodingFrom valueOf(String name)
valuesback to summary
public static ServletContextResponse.EncodingFrom[] values()
org.eclipse.jetty.ee10.servlet back to summary

private Class ServletContextResponse.HttpFieldsWrapper

extends Wrapper
Class Inheritance

Wrapper of the response HttpFields to allow specific values to be intercepted.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public HttpField
onAddField(HttpField
The field being added.
field
)

Overrides org.eclipse.jetty.http.HttpFields.Mutable.Wrapper.onAddField.

Called when a field is added (including as part of a put).

public boolean
onRemoveField(HttpField
The field being removed.
field
)

Overrides org.eclipse.jetty.http.HttpFields.Mutable.Wrapper.onRemoveField.

Called when a field is removed (including as part of a put).

public HttpField
private HttpField
private HttpField
Inherited from org.eclipse.jetty.http.HttpFields.Mutable.Wrapper:
addclearlistIteratorputsizestream

Constructor Detail

HttpFieldsWrapperback to summary
public HttpFieldsWrapper(HttpFields.Mutable fields)

Method Detail

onAddFieldback to summary
public HttpField onAddField(HttpField field)

Overrides org.eclipse.jetty.http.HttpFields.Mutable.Wrapper.onAddField.

Doc from org.eclipse.jetty.http.HttpFields.Mutable.Wrapper.onAddField.

Called when a field is added (including as part of a put).

Parameters
field:HttpField

The field being added.

Returns:HttpField

The field to add, or null if the add is to be ignored.

Annotations
@Override
onRemoveFieldback to summary
public boolean onRemoveField(HttpField field)

Overrides org.eclipse.jetty.http.HttpFields.Mutable.Wrapper.onRemoveField.

Doc from org.eclipse.jetty.http.HttpFields.Mutable.Wrapper.onRemoveField.

Called when a field is removed (including as part of a put).

Parameters
field:HttpField

The field being removed.

Returns:boolean

True if the field should be removed, false otherwise.

Annotations
@Override
onReplaceFieldback to summary
public HttpField onReplaceField(HttpField oldField, HttpField newField)

Overrides org.eclipse.jetty.http.HttpFields.Mutable.Wrapper.onReplaceField.

Annotations
@Override
setContentLengthback to summary
private HttpField setContentLength(HttpField field)
setContentTypeback to summary
private HttpField setContentType(HttpField field)
org.eclipse.jetty.ee10.servlet back to summary

protected final Enum ServletContextResponse.OutputType

extends Enum<ServletContextResponse.OutputType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final ServletContextResponse.OutputType
public static final ServletContextResponse.OutputType
public static final ServletContextResponse.OutputType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ServletContextResponse.OutputType
public static ServletContextResponse.OutputType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

NONEback to summary
public static final ServletContextResponse.OutputType NONE
STREAMback to summary
public static final ServletContextResponse.OutputType STREAM
WRITERback to summary
public static final ServletContextResponse.OutputType WRITER

Constructor Detail

OutputTypeback to summary
private OutputType()

Method Detail

valueOfback to summary
public static ServletContextResponse.OutputType valueOf(String name)
valuesback to summary
public static ServletContextResponse.OutputType[] values()