Title: JSP, OutputStreamWriter

Has anyone been able to create a PDF document and then stream it to a JSP through the JSPWriter out?  I am trying to prompt the user to download the dynamic PDF I am creating (through a Taglib), and want to stream it back to the client using the JSPWriter.  I am using something similar to the following, and I can save the file ok without any errors, but when I go to view the file from my local machine, its blank. This is done inside an End Tag of a JSP Taglib.


...
byte[] bytes = baos.toByteArray();
for(int i = 0; i <bytes.length; i++)
{
    pageContext.getOut().write( bytes[i] );
}
...


I can't use the getOutputStream because everytime I do, I get an IllegalStateException saying I can't use the getOutputStream() for this response.  Although if I do use it, it will throw the error to the console, but still allow me to download the file.  And when I do it this way, it saves the file correctly.  Any help on this would be greatly appreciated.  Thank you.

Daniel

Reply via email to