Class ExpiresFilter.XServletOutputStream
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
- Enclosing class:
ExpiresFilter
ServletOutputStream to trap the "Start Write Response Body" event.-
Constructor Summary
ConstructorsConstructorDescriptionXServletOutputStream(ServletOutputStream servletOutputStream, HttpServletRequest request, ExpiresFilter.XHttpServletResponse response) Creates a new XServletOutputStream wrapping the given stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidflush()booleanisReady()Returnstrueif it is allowable to call any method that may write data (e.g.voidprint(boolean b) Writes abooleanvalue to the client, with no carriage return-line feed (CRLF) character at the end.voidprint(char c) Writes a character to the client, with no carriage return-line feed (CRLF) at the end.voidprint(double d) Writes adoublevalue to the client, with no carriage return-line feed (CRLF) at the end.voidprint(float f) Writes afloatvalue to the client, with no carriage return-line feed (CRLF) at the end.voidprint(int i) Writes an int to the client, with no carriage return-line feed (CRLF) at the end.voidprint(long l) Writes alongvalue to the client, with no carriage return-line feed (CRLF) at the end.voidWrites aStringto the client, without a carriage return-line feed (CRLF) character at the end.voidprintln()Writes a carriage return-line feed (CRLF) to the client.voidprintln(boolean b) Writes abooleanvalue to the client, followed by a carriage return-line feed (CRLF).voidprintln(char c) Writes a character to the client, followed by a carriage return-line feed (CRLF).voidprintln(double d) Writes adoublevalue to the client, followed by a carriage return-line feed (CRLF).voidprintln(float f) Writes afloatvalue to the client, followed by a carriage return-line feed (CRLF).voidprintln(int i) Writes an int to the client, followed by a carriage return-line feed (CRLF) character.voidprintln(long l) Writes alongvalue to the client, followed by a carriage return-line feed (CRLF).voidWrites aStringto the client, followed by a carriage return-line feed (CRLF).voidsetWriteListener(WriteListener listener) Sets theWriteListenerfor thisServletOutputStreamand thereby switches to non-blocking IO.voidwrite(byte[] b) voidwrite(byte[] b, int off, int len) voidwrite(int b) Methods inherited from class ServletOutputStream
writeMethods inherited from class OutputStream
nullOutputStream
-
Constructor Details
-
XServletOutputStream
public XServletOutputStream(ServletOutputStream servletOutputStream, HttpServletRequest request, ExpiresFilter.XHttpServletResponse response) Creates a new XServletOutputStream wrapping the given stream.- Parameters:
servletOutputStream- the ServletOutputStream to wraprequest- the HTTP servlet requestresponse- the wrapped HTTP servlet response
-
-
Method Details
-
close
Description copied from class:jakarta.servlet.ServletOutputStreamIf this method is called when the output stream is in non-blocking mode, it will immediately return with the stream effectively closed, even if the stream contains buffered data that is yet to be written to client. The container will write this data out in the background. If this process fails the
WriteListener.onError(Throwable)method will be invoked as normal.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classServletOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
print
Description copied from class:jakarta.servlet.ServletOutputStreamWrites abooleanvalue to the client, with no carriage return-line feed (CRLF) character at the end.- Overrides:
printin classServletOutputStream- Parameters:
b- thebooleanvalue to send to the client- Throws:
IOException- if an input or output exception occurred
-
print
Description copied from class:jakarta.servlet.ServletOutputStreamWrites a character to the client, with no carriage return-line feed (CRLF) at the end.- Overrides:
printin classServletOutputStream- Parameters:
c- the character to send to the client- Throws:
IOException- if an input or output exception occurred
-
print
Description copied from class:jakarta.servlet.ServletOutputStreamWrites adoublevalue to the client, with no carriage return-line feed (CRLF) at the end.- Overrides:
printin classServletOutputStream- Parameters:
d- thedoublevalue to send to the client- Throws:
IOException- if an input or output exception occurred
-
print
Description copied from class:jakarta.servlet.ServletOutputStreamWrites afloatvalue to the client, with no carriage return-line feed (CRLF) at the end.- Overrides:
printin classServletOutputStream- Parameters:
f- thefloatvalue to send to the client- Throws:
IOException- if an input or output exception occurred
-
print
Description copied from class:jakarta.servlet.ServletOutputStreamWrites an int to the client, with no carriage return-line feed (CRLF) at the end.- Overrides:
printin classServletOutputStream- Parameters:
i- the int to send to the client- Throws:
IOException- if an input or output exception occurred
-
print
Description copied from class:jakarta.servlet.ServletOutputStreamWrites alongvalue to the client, with no carriage return-line feed (CRLF) at the end.- Overrides:
printin classServletOutputStream- Parameters:
l- thelongvalue to send to the client- Throws:
IOException- if an input or output exception occurred
-
print
Description copied from class:jakarta.servlet.ServletOutputStreamWrites aStringto the client, without a carriage return-line feed (CRLF) character at the end.- Overrides:
printin classServletOutputStream- Parameters:
s- theStringto send to the client- Throws:
IOException- if an input or output exception occurred
-
println
Description copied from class:jakarta.servlet.ServletOutputStreamWrites a carriage return-line feed (CRLF) to the client.- Overrides:
printlnin classServletOutputStream- Throws:
IOException- if an input or output exception occurred
-
println
Description copied from class:jakarta.servlet.ServletOutputStreamWrites abooleanvalue to the client, followed by a carriage return-line feed (CRLF).- Overrides:
printlnin classServletOutputStream- Parameters:
b- thebooleanvalue to write to the client- Throws:
IOException- if an input or output exception occurred
-
println
Description copied from class:jakarta.servlet.ServletOutputStreamWrites a character to the client, followed by a carriage return-line feed (CRLF).- Overrides:
printlnin classServletOutputStream- Parameters:
c- the character to write to the client- Throws:
IOException- if an input or output exception occurred
-
println
Description copied from class:jakarta.servlet.ServletOutputStreamWrites adoublevalue to the client, followed by a carriage return-line feed (CRLF).- Overrides:
printlnin classServletOutputStream- Parameters:
d- thedoublevalue to write to the client- Throws:
IOException- if an input or output exception occurred
-
println
Description copied from class:jakarta.servlet.ServletOutputStreamWrites afloatvalue to the client, followed by a carriage return-line feed (CRLF).- Overrides:
printlnin classServletOutputStream- Parameters:
f- thefloatvalue to write to the client- Throws:
IOException- if an input or output exception occurred
-
println
Description copied from class:jakarta.servlet.ServletOutputStreamWrites an int to the client, followed by a carriage return-line feed (CRLF) character.- Overrides:
printlnin classServletOutputStream- Parameters:
i- the int to write to the client- Throws:
IOException- if an input or output exception occurred
-
println
Description copied from class:jakarta.servlet.ServletOutputStreamWrites alongvalue to the client, followed by a carriage return-line feed (CRLF).- Overrides:
printlnin classServletOutputStream- Parameters:
l- thelongvalue to write to the client- Throws:
IOException- if an input or output exception occurred
-
println
Description copied from class:jakarta.servlet.ServletOutputStreamWrites aStringto the client, followed by a carriage return-line feed (CRLF).- Overrides:
printlnin classServletOutputStream- Parameters:
s- theStringto write to the client- Throws:
IOException- if an input or output exception occurred
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
isReady
public boolean isReady()Description copied from class:jakarta.servlet.ServletOutputStreamReturnstrueif it is allowable to call any method that may write data (e.g.write(),print()orflush). In blocking mode, this method will always returntrue, but a subsequent call to a method that writes data may block. In non-blocking mode this method may returnfalse, in which case it is illegal to call a method that writes data and anIllegalStateExceptionMUST be thrown. WhenWriteListener.onWritePossible()is called, a call to this method that returnedtrueis implicit.If this method returns
falseand aWriteListenerhas been set viaServletOutputStream.setWriteListener(WriteListener), then container will subsequently invokeWriteListener.onWritePossible()once a write operation becomes possible without blocking. Other than the initial call,WriteListener.onWritePossible()will only be called if and only if this method is called and returns false.- Specified by:
isReadyin classServletOutputStream- Returns:
trueif data can be written without blocking, otherwise returnsfalse.
-
setWriteListener
Description copied from class:jakarta.servlet.ServletOutputStreamSets theWriteListenerfor thisServletOutputStreamand thereby switches to non-blocking IO. It is only valid to switch to non-blocking IO within async processing or HTTP upgrade processing.- Specified by:
setWriteListenerin classServletOutputStream- Parameters:
listener- The non-blocking IO write listener
-