The problem is that you're opening the output stream at the beginning of
your jsp and then reopening the output stream by calling
response.getOutputStream(). I believe you can call response.reset() to
fix this problem:
<%
response.reset();
response.setContentType("image/png");
java.io.OutputStream os = response.getOutputStream();
java.awt.image.BufferedImage buffer = (java.awt.image.BufferedImage)
request.getAttribute("imageBuffer");
javax.imageio.ImageIO.write(buffer,"png",os);
os.flush();
os.close();
%>
Regards,
Thad Smith
-----Original Message-----
From: Daniel Watrous [mailto:[EMAIL PROTECTED]
Sent: Monday, April 18, 2005 4:20 PM
To: [email protected]
Subject: binary view
I have an action in my application that generates a PNG image from
some text stored in a session object. My view is very simple:
<[EMAIL PROTECTED] contentType="image/png"%>
<%
java.io.OutputStream os = response.getOutputStream();
java.awt.image.BufferedImage buffer = (java.awt.image.BufferedImage)
request.getAttribute("imageBuffer");
javax.imageio.ImageIO.write(buffer,"png",os);
os.close();
%>
Thats it. My action loads imageBuffer with the image data.
The first time I load the page I get the error:
"java.lang.IllegalStateException: getOutputStream() has already been
called for this response"
Is there a better way to accomplish what I am after? I would prefer
to load the page one time and have it work, rather than the refresh.
Thanks in advance...
DW
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]