OK, I have a little bit of time so I'll drop some more in the hope you're about to change your display name and are still reading.
The implicit 'out' object is a JsPWriter and you cannot write binary data to it. This rules out one of your options.
You cannot get a JspWriter then an OutputStream or vice versa, this will always cause an IllegalStateException. It's a bit hard to flush a writer if you're not allowed to have one. This also rules out one of your options.
If the writer is already opened, you wouldn't be able to write binary data in a JSP without causing a IllegalStateException. Since it is possible for JSPs to output binary data, this also rules out one of your options.
To output binary data in a JSP, there are some tricks and pitfalls to be aware of.
The hard rule is:
If you load the BinaryStream, anything that causes the writer to be called will cause an exception. This is what we have to be careful of.
Firstly, any white-space in your JSP will cause the JspWRiter to be called and will kill you application. White space can look like this:
The carriage return outside the scriptlets between the first and second blocks is actually HTML data and gets sent via the JspWriter. You need to do this:
I was using an editor once that hid a trailing carriage return and this caused my JSP to keep crashing. Be aware of this, it's very annoying.
The other thing to be aware of is that any exceptions that occur will cuase the container to forward to the error handling page. When it sends the error page, it will try to send it using the JspWriter. You guessed it, this causes an exception. You can either wrap your own try/catch block, or just live with this behaviour -
you should try to write the JSP so that it doesn't throw any exceptions anyway.
Hopefully this answered your question and possibly the next one too.
Dave