This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes Problem --  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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem --  getOutputStream() has already been called for this response" Watch "Problem --  getOutputStream() has already been called for this response" New topic
Author

Problem -- getOutputStream() has already been called for this response

yogesh totare
Greenhorn

Joined: Feb 02, 2005
Posts: 15
Hi All,

I have a jsp code(statement) like
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder (response.getOutputStream());

while runing it gives exception on the jboss console like

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

can anyone help me to solve this problem

Thanks in advance,

Yogesh...
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You'll have a much easier time doing this from a servlet than from a JSP.
If you have so much as a single whitespace character preceding your scriptlet that references the outputstream, you will see this error.

Any whitespace after it will also cause this problem.
JSPs are best for formatting text (html).


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem -- getOutputStream() has already been called for this response
 
Similar Threads
problem with servlet->applet communication
Struts and output streams
getting JasperException
Why IllegalStateException ?
Setting header and fetching OutputStream from Action