You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Daniel Watrous <dw...@gmail.com> on 2005/04/18 23:19:34 UTC

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:

<%@page 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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: binary view

Posted by Larry Meadors <la...@gmail.com>.
Why even bother with a jsp?

You have the response object in your action, just start spewing data into 
it.

Larry

On 4/18/05, Daniel Watrous <dw...@gmail.com> wrote:
> 
> 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:
> 
> <%@page 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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

RE: binary view

Posted by Folashade Adeyosoye <sh...@gmail.com>.
This might be a good case to write a custom tag.



-----Original Message-----
From: Daniel Watrous [mailto:dwmaillist@gmail.com] 
Sent: Monday, April 18, 2005 5:20 PM
To: user@struts.apache.org
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:

<%@page 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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org