wood burning stoves 2.0*
The moose likes Struts and the fly likes getOutputStream()  has already been called for this response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "getOutputStream()  has already been called for this response" Watch "getOutputStream()  has already been called for this response" New topic
Author

getOutputStream() has already been called for this response

mo sayed
Ranch Hand

Joined: Jan 25, 2006
Posts: 88
I'm currently developing a web application using struts 1.3.5 with tiles deployed on XP under tomcat 5.5

I've implemented a download facility to enable users to download
files by clicking on appropriate links. This has been achieved
using the struts file download action mentioned at

StrutsFileDownloadAction

The application works fine, and i can download a number of different
formats including pdf, zip etc.

However Problems arise when I perform stress testing using JMeter.

The following exception is thrown

"java.lang.IllegalStateException: getOutputStream() has already been called for this response"


I have the following settings for Jmeter.

Number of Threads: 1

Ramp-up Period : 1

Loop count : 50

I'd appreciate it if anyone could enlighten me as to what is actually going on.

The code is as follows


A partial stack trace is given below


2007/7/04 17:07 40 [ERROR] org.apache.catalina.core.ApplicationDispatcher.invoke:L - 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:599)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:195)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:111)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:111)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:111)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:111)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:111)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:111)
...............................................................
...............................................................
...............................................................
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:111)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:111)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:124)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:117)
at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:174)
at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:115)
at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:75)
at org.apache.jsp.WEB_002dINF.common.Layout_jsp._jspService(Layout_jsp.java:85)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
...............................................................
...............................................................
...............................................................




kind regards,

Mo


<a href="http://moongrails.blogspot.com/" rel="nofollow">grails</a>
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I've seen situations where this exception is thrown because the download is being done within a tiles template. One way to avoid this would be to make sure a separate window is opened when the file downloads. You can do this by specifying target="_blank" in yor form tag.


Merrill
Consultant, Sima Solutions
mo sayed
Ranch Hand

Joined: Jan 25, 2006
Posts: 88
Merrill

Thanks for the swift reply.


've seen situations where this exception is thrown because the download is being done within a tiles template. One way to avoid this would be to make sure a separate window is opened when the file downloads. You can do this by specifying target="_blank" in yor form tag.


I tried this but unfortunately I'm still getting the same error.
I'd appreciate any other suggestions you may have.

kind regards,
Mo
John Simpson
Greenhorn

Joined: Sep 10, 2007
Posts: 25
Originally posted by mo sayed:
Merrill

Thanks for the swift reply.



I tried this but unfortunately I'm still getting the same error.
I'd appreciate any other suggestions you may have.

kind regards,
Mo



Are you using two System.out & creating an OutputStream in your code?

I have seen this as the problem in other forums.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getOutputStream() has already been called for this response
 
Similar Threads
problem with getOutputStream() has already been called for this response
java.lang.IllegalStateException:- when generating excel report
Error:getOutputStream() has already been called for this response
getOutputStream() has already been called for this response
Web app IllegalStateException: getOutputStream()..