aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Exception problem about OutputStream already obtained Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Exception problem about OutputStream already obtained " Watch "Exception problem about OutputStream already obtained " New topic
Author

Exception problem about OutputStream already obtained

max seto
Greenhorn

Joined: Feb 06, 2004
Posts: 3
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!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception problem about OutputStream already obtained