Simply put:
facesContext.getResponseStream() returns null.
facesContext.getReponse().getOutputStream() throws the following exception:
java.lang.IllegalStateException: Can’t get an OutputStream while a Writer is already in use
So I cannot see any way of getting an Stream rather than a Writer.
I was trying to get Ed Wissels technique to work to allow xpages to return binary as this is something I would dearly like to have for my current project. I can’t see how it’s possible.
I also have a problem with any xpage Java placed in WebContent/WEB_INF being cached permanently and needing a server restart.
Anyone have any experience with the ResponseStream objects? The ResponseWriter works fine but handles only text.
No love for xpages yet!
S
EDIT: I am using this code in the afterRenderReponse event.
var rs = facesContext.getResponseStream();
var rw = facesContext.getResponseWriter();
if(rs == null ) {
rw.write("stream == null");
} else {
rw.write("we have a stream");
}
Always outputs stream == null
Sounds to me like the xpage system is always instantiating the PrintWriter object even when all rendering is turned off and this blocks any attempt at getting at the OutputStream.
I have tried closing/flushing/ending/null’ing the ResponseWriter object, but nothing seems to work.