This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception problem about OutputStream already obtained

 
max seto
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
i'm writing a code to retrieve BLOB data from Oracle in servlet and convert it to byte[]. then forward the byte[] value to JSP for display. i'm using IBM websphere for development. The code below is what i used to display the BLOB data in JSP.
byte[] blobArr = (byte[])request.getAttribute("blobArr");
String fileType = (String)request.getAttribute("fileType");
response.reset();
response.resetBuffer();
response.setContentType(fileType);
if(fileType.equals("text/plain")) {
ByteArrayInputStream bin = new ByteArrayInputStream(blobArr);
int c;
while((c = bin.read()) != -1) {
out.print((char)c);
}
}
else {
response.getOutputStream().write(blobArr);
response.flushBuffer();
}
the problem is that although it displays the data(doc, xls...) well, it throws an exception error out :
java.lang.IllegalStateException: OutputStream already obtained
i know that it occurs when calling the method getOutputStream( ). however, why does it occur? and how to prevent it? pls someone tell me. thanks a lot!!
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic