When you return SUCCESS you're asking S2 to process the response normally. I'd 
assume you'd need to return null to indicate that S2 shouldn't do anything.

I don't actually know if that works, because there's a stream result type 
designed specifically for this situation.

Dave


--- On Wed, 12/10/08, red phoenix <[EMAIL PROTECTED]> wrote:

> From: red phoenix <[EMAIL PROTECTED]>
> Subject: getOutputStream() has already been called for this response
> To: "Struts Users Mailing List" <user@struts.apache.org>
> Date: Wednesday, December 10, 2008, 11:26 AM
> I use struts2.0.11,I want to show a picture by struts
> action,like follows:
> public String showphoto() throws Exception{
>     response=ServletActionContext.getResponse();
>     response.setContentType("image/png");
>     ...
>     InputStream in = picture.getBinaryStream();
>     OutputStream out = response.getOutputStream();
>     byte[] buf = new byte[1024];
>     int len;
>     while ((len = in.read(buf)) != -1){
>          out.write(buf, 0, len);
>     }
>     in.close();
>     out.close();
>     response.flushBuffer();
>     return SUCCESS;
>  }
> 
> When I run above code,it can run well,and it can show
> picture in jsp,but I
> find it write error information in tomcat6,like follows:
> fatal: Servlet.service() for servlet jsp threw exception
> java.lang.IllegalStateException: getOutputStream() has
> already been called
> for this response
>  at
> org.apache.catalina.connector.Response.getWriter(Response.java:610)
>  at
> org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
>  at
> javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:112)
>  at
> org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)
> 
> Why raise above error in tomcat6? How to correct my code to
> correct above
> error?
> Thanks in advance!

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to