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

public Class ResponseWriter

extends PrintWriter
Class Inheritance
Imports
java.io.IOException, .InterruptedIOException, .PrintWriter, java.util.Formatter, .Locale, jakarta.servlet.ServletResponse, jakarta.servlet.http.HttpServletResponse, org.eclipse.jetty.io.EofException, .RuntimeIOException, .WriteThroughWriter, org.slf4j.Logger, .LoggerFactory

Specialized PrintWriter for servlet Responses

An instance of ResponseWriter is the PrintWriter subclass returned by HttpServletResponse#getWriter(). It differs from the standard PrintWriter in that:

Field Summary

Modifier and TypeField and Description
private final String
private Formatter
private IOException
private boolean
private final Locale
private final WriteThroughWriter
private static final Logger
Inherited from java.io.PrintWriter:
out

Constructor Summary

AccessConstructor and Description
public
ResponseWriter(WriteThroughWriter writer, Locale locale, String encoding)

Method Summary

Modifier and TypeMethod and Description
public boolean
checkError()

Overrides java.io.PrintWriter.checkError.

Flushes the stream if it's not closed and checks its error state.
protected void
clearError()

Overrides java.io.PrintWriter.clearError.

Clears the error state of this stream.
public void
close()

Overrides java.io.PrintWriter.close.

Implements java.io.Closeable.close.

Closes the stream and releases any system resources associated with it.
public void
flush()

Overrides java.io.PrintWriter.flush.

Implements java.io.Flushable.flush.

Flushes the stream.
public PrintWriter
format(String
A format string as described in Format string syntax.
format
,
Object...
Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.
args
)

Overrides java.io.PrintWriter.format.

Writes a formatted string to this writer using the specified format string and arguments.
public PrintWriter
format(Locale
The locale to apply during formatting. If l is null then no localization is applied.
locale
,
String
A format string as described in Format string syntax.
format
,
Object...
Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.
args
)

Overrides java.io.PrintWriter.format.

Writes a formatted string to this writer using the specified format string and arguments.
public boolean
isFor(Locale locale, String encoding)

private void
isOpen()

Check to make sure that the stream has not been closed

pack-priv void
markAsClosed()

Used to mark this writer as closed during any asynchronous completion operation.

public PrintWriter
printf(String
A format string as described in Format string syntax.
format
,
Object...
Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.
args
)

Overrides java.io.PrintWriter.printf.

A convenience method to write a formatted string to this writer using the specified format string and arguments.
public PrintWriter
printf(Locale
The locale to apply during formatting. If l is null then no localization is applied.
l
,
String
A format string as described in Format string syntax.
format
,
Object...
Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.
args
)

Overrides java.io.PrintWriter.printf.

A convenience method to write a formatted string to this writer using the specified format string and arguments.
public void
println()

Overrides java.io.PrintWriter.println.

Terminates the current line by writing the line separator string.
public void
println(boolean
the boolean value to be printed
b
)

Overrides java.io.PrintWriter.println.

Prints a boolean value and then terminates the line.
public void
println(char
the char value to be printed
c
)

Overrides java.io.PrintWriter.println.

Prints a character and then terminates the line.
public void
println(int
the int value to be printed
x
)

Overrides java.io.PrintWriter.println.

Prints an integer and then terminates the line.
public void
println(long
the long value to be printed
x
)

Overrides java.io.PrintWriter.println.

Prints a long integer and then terminates the line.
public void
println(float
the float value to be printed
x
)

Overrides java.io.PrintWriter.println.

Prints a floating-point number and then terminates the line.
public void
println(double
the double value to be printed
x
)

Overrides java.io.PrintWriter.println.

Prints a double-precision floating-point number and then terminates the line.
public void
println(char[]
the array of char values to be printed
s
)

Overrides java.io.PrintWriter.println.

Prints an array of characters and then terminates the line.
public void
println(String
the String value to be printed
s
)

Overrides java.io.PrintWriter.println.

Prints a String and then terminates the line.
public void
println(Object
The Object to be printed.
x
)

Overrides java.io.PrintWriter.println.

Prints an Object and then terminates the line.
public void
private void
protected void
setError()

Overrides java.io.PrintWriter.setError.

Sets the error state of the stream to true.
public void
write(int
int specifying a character to be written.
c
)

Overrides java.io.PrintWriter.write.

Writes a single character.
public void
write(char[]
Array of characters
buf
,
int
Offset from which to start writing characters
off
,
int
Number of characters to write
len
)

Overrides java.io.PrintWriter.write.

Writes A Portion of an array of characters.
public void
write(char[]
Array of characters to be written
buf
)

Overrides java.io.PrintWriter.write.

Writes an array of characters.
public void
write(String
A String
s
,
int
Offset from which to start writing characters
off
,
int
Number of characters to write
len
)

Overrides java.io.PrintWriter.write.

Writes a portion of a string.
public void
write(String
String to be written
s
)

Overrides java.io.PrintWriter.write.

Writes a string.
Inherited from java.io.PrintWriter:
appendappendappend

Field Detail

_encodingback to summary
private final String _encoding
_formatterback to summary
private Formatter _formatter
_ioExceptionback to summary
private IOException _ioException
_isClosedback to summary
private boolean _isClosed
_localeback to summary
private final Locale _locale
_writerback to summary
private final WriteThroughWriter _writer
LOGback to summary
private static final Logger LOG

Constructor Detail

ResponseWriterback to summary
public ResponseWriter(WriteThroughWriter writer, Locale locale, String encoding)

Method Detail

checkErrorback to summary
public boolean checkError()

Overrides java.io.PrintWriter.checkError.

Doc from java.io.PrintWriter.checkError.

Flushes the stream if it's not closed and checks its error state.

Returns:boolean

true if and only if this stream has encountered an IOException, or the setError method has been invoked

Annotations
@Override
clearErrorback to summary
protected void clearError()

Overrides java.io.PrintWriter.clearError.

Doc from java.io.PrintWriter.clearError.

Clears the error state of this stream.

This method will cause subsequent invocations of checkError() to return false until another write operation fails and invokes setError().

Annotations
@Override
closeback to summary
public void close()

Overrides java.io.PrintWriter.close.

Implements java.io.Closeable.close.

Doc from java.io.PrintWriter.close.

Closes the stream and releases any system resources associated with it. Closing a previously closed stream has no effect.

Annotations
@Override
flushback to summary
public void flush()

Overrides java.io.PrintWriter.flush.

Implements java.io.Flushable.flush.

Doc from java.io.PrintWriter.flush.

Flushes the stream.

Annotations
@Override
formatback to summary
public PrintWriter format(String format, Object... args)

Overrides java.io.PrintWriter.format.

Doc from java.io.PrintWriter.format.

Writes a formatted string to this writer using the specified format string and arguments. If automatic flushing is enabled, calls to this method will flush the output buffer.

The locale always used is the one returned by Locale.getDefault(), regardless of any previous invocations of other formatting methods on this object.

Parameters
format:String

A format string as described in Format string syntax.

args:Object[]

Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.

Returns:PrintWriter

This writer

Annotations
@Override
formatback to summary
public PrintWriter format(Locale locale, String format, Object... args)

Overrides java.io.PrintWriter.format.

Doc from java.io.PrintWriter.format.

Writes a formatted string to this writer using the specified format string and arguments. If automatic flushing is enabled, calls to this method will flush the output buffer.

Parameters
locale:Locale

The locale to apply during formatting. If l is null then no localization is applied.

format:String

A format string as described in Format string syntax.

args:Object[]

Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.

Returns:PrintWriter

This writer

Annotations
@Override
isForback to summary
public boolean isFor(Locale locale, String encoding)
isOpenback to summary
private void isOpen() throws IOException

Check to make sure that the stream has not been closed

markAsClosedback to summary
pack-priv void markAsClosed()

Used to mark this writer as closed during any asynchronous completion operation.

printfback to summary
public PrintWriter printf(String format, Object... args)

Overrides java.io.PrintWriter.printf.

Doc from java.io.PrintWriter.printf.

A convenience method to write a formatted string to this writer using the specified format string and arguments. If automatic flushing is enabled, calls to this method will flush the output buffer.

An invocation of this method of the form out.printf(format, args) behaves in exactly the same way as the invocation

out.format(format, args)
out.format(format, args)
Parameters
format:String

A format string as described in Format string syntax.

args:Object[]

Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.

Returns:PrintWriter

This writer

Annotations
@Override
printfback to summary
public PrintWriter printf(Locale l, String format, Object... args)

Overrides java.io.PrintWriter.printf.

Doc from java.io.PrintWriter.printf.

A convenience method to write a formatted string to this writer using the specified format string and arguments. If automatic flushing is enabled, calls to this method will flush the output buffer.

An invocation of this method of the form out.printf(l, format, args) behaves in exactly the same way as the invocation

out.format(l, format, args)
out.format(l, format, args)
Parameters
l:Locale

The locale to apply during formatting. If l is null then no localization is applied.

format:String

A format string as described in Format string syntax.

args:Object[]

Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.

Returns:PrintWriter

This writer

Annotations
@Override
printlnback to summary
public void println()

Overrides java.io.PrintWriter.println.

Doc from java.io.PrintWriter.println.

Terminates the current line by writing the line separator string. The line separator is System#lineSeparator() and is not necessarily a single newline character ('\n').

Annotations
@Override
printlnback to summary
public void println(boolean b)

Overrides java.io.PrintWriter.println.

Doc from java.io.PrintWriter.println.

Prints a boolean value and then terminates the line. This method behaves as though it invokes print(boolean) and then println().

Parameters
b:boolean

the boolean value to be printed

Annotations
@Override
printlnback to summary
public void println(char c)

Overrides java.io.PrintWriter.println.

Doc from java.io.PrintWriter.println.

Prints a character and then terminates the line. This method behaves as though it invokes print(char) and then println().

Parameters
c:char

the char value to be printed

Annotations
@Override
printlnback to summary
public void println(int x)

Overrides java.io.PrintWriter.println.

Doc from java.io.PrintWriter.println.

Prints an integer and then terminates the line. This method behaves as though it invokes print(int) and then println().

Parameters
x:int

the int value to be printed

Annotations
@Override
printlnback to summary
public void println(long x)

Overrides java.io.PrintWriter.println.

Doc from java.io.PrintWriter.println.

Prints a long integer and then terminates the line. This method behaves as though it invokes print(long) and then println().

Parameters
x:long

the long value to be printed

Annotations
@Override
printlnback to summary
public void println(float x)

Overrides java.io.PrintWriter.println.

Doc from java.io.PrintWriter.println.

Prints a floating-point number and then terminates the line. This method behaves as though it invokes print(float) and then println().

Parameters
x:float

the float value to be printed

Annotations
@Override
printlnback to summary
public void println(double x)

Overrides java.io.PrintWriter.println.

Doc from java.io.PrintWriter.println.

Prints a double-precision floating-point number and then terminates the line. This method behaves as though it invokes print(double) and then println().

Parameters
x:double

the double value to be printed

Annotations
@Override
printlnback to summary
public void println(char[] s)

Overrides java.io.PrintWriter.println.

Doc from java.io.PrintWriter.println.

Prints an array of characters and then terminates the line. This method behaves as though it invokes print(char[]) and then println().

Parameters
s:char[]

the array of char values to be printed

Annotations
@Override
printlnback to summary
public void println(String s)

Overrides java.io.PrintWriter.println.

Doc from java.io.PrintWriter.println.

Prints a String and then terminates the line. This method behaves as though it invokes print(String) and then println().

Parameters
s:String

the String value to be printed

Annotations
@Override
printlnback to summary
public void println(Object x)

Overrides java.io.PrintWriter.println.

Doc from java.io.PrintWriter.println.

Prints an Object and then terminates the line. This method calls at first String.valueOf(x) to get the printed object's string value, then behaves as though it invokes print(String) and then println().

Parameters
x:Object

The Object to be printed.

Annotations
@Override
reopenback to summary
public void reopen()
setErrorback to summary
private void setError(Throwable th)
setErrorback to summary
protected void setError()

Overrides java.io.PrintWriter.setError.

Doc from java.io.PrintWriter.setError.

Sets the error state of the stream to true.

This method will cause subsequent invocations of checkError() to return true until clearError() is invoked.

Annotations
@Override
writeback to summary
public void write(int c)

Overrides java.io.PrintWriter.write.

Doc from java.io.PrintWriter.write.

Writes a single character.

Parameters
c:int

int specifying a character to be written.

Annotations
@Override
writeback to summary
public void write(char[] buf, int off, int len)

Overrides java.io.PrintWriter.write.

Doc from java.io.PrintWriter.write.

Writes A Portion of an array of characters.

Parameters
buf:char[]

Array of characters

off:int

Offset from which to start writing characters

len:int

Number of characters to write

Annotations
@Override
writeback to summary
public void write(char[] buf)

Overrides java.io.PrintWriter.write.

Doc from java.io.PrintWriter.write.

Writes an array of characters. This method cannot be inherited from the Writer class because it must suppress I/O exceptions.

Parameters
buf:char[]

Array of characters to be written

Annotations
@Override
writeback to summary
public void write(String s, int off, int len)

Overrides java.io.PrintWriter.write.

Doc from java.io.PrintWriter.write.

Writes a portion of a string.

Parameters
s:String

A String

off:int

Offset from which to start writing characters

len:int

Number of characters to write

Annotations
@Override
writeback to summary
public void write(String s)

Overrides java.io.PrintWriter.write.

Doc from java.io.PrintWriter.write.

Writes a string. This method cannot be inherited from the Writer class because it must suppress I/O exceptions.

Parameters
s:String

String to be written

Annotations
@Override