wood burning stoves 2.0*
The moose likes JSP and the fly likes java.lang.IllegalStateException: getOutputStream() has already been called for this response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "java.lang.IllegalStateException: getOutputStream() has already been called for this response" Watch "java.lang.IllegalStateException: getOutputStream() has already been called for this response" New topic
Author

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

manishkumarlal cs
Greenhorn

Joined: Oct 25, 2005
Posts: 11
Hi,
I am trying this code to generate captcha and provide the user to enter the values in text field.
The Captcha is appearing,but the text input fields are not appearing.
I am getting this error java.lang.IllegalStateException: getOutputStream() has already been called for this response

Here is the JSP

And the error

equest.getSession().getId()C26FB56BC507153AE418591175866518
Apr 20, 2010 11:12:09 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: 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 org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118)
at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:188)
at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:118)
at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:77)
at org.apache.jsp.TestR_jsp._jspService(TestR_jsp.java:158)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)

Can anyone help?
Amit Vinod Dali
Ranch Hand

Joined: Apr 14, 2010
Posts: 42
you should never close the servlet's output stream. Leave that up to the servlet container.
Please go through the reply in the following link
IllegalStateException-getOutputStream-has-already-been
manishkumarlal cs
Greenhorn

Joined: Oct 25, 2005
Posts: 11
Thanks

I have deleted the line
responseOutputStream.close();

But still its giving the same error.
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 2885
    
  13

"manishkumarlal cs", please check your private messages for a warning from JavaRanch.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
My Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 2885
    
  13

Please UseCodeTags when you post a code. It's unnecessarily hard to read the code otherwise.
Please edit your post to add code tags by clicking the button.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.IllegalStateException: getOutputStream() has already been called for this response
 
Similar Threads
displaying a image in a JSP
Need an attribute to be available in different places (SOLVED)
my image tag will not call servlet please help
my captcha font and background are not good
Getting null while trying to get value of Multiple list