Win a copy of Getting started with Java programming language this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
yogesh totare
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!