我嘗試從Oracle數據庫訪問圖像數據並在jsp上顯示圖像。寫下面的代碼。 在Oracle數據庫中的圖像數據時在JSP中顯示圖像圖像
<%
try
{
ResultSet rs=stmt.executeQuery("select * from PICTABLE where ID=200");
if(rs.next())
{
Blob b1=rs.getBlob("PIC");
byte x[]=b1.getBytes(1, (int)b1.length());
OutputStream o=response.getOutputStream();
o.write(x);
o.close();
}
System.out.println("Done");
}
catch(Exception ex)
{
ex.printStackTrace();
}
%>
當運行此代碼並使用IE瀏覽器,然後顯示圖像有錯誤
[java.lang.IllegalStateException: getOutputStream() has already been called for this response] with root cause
java.lang.IllegalStateException: getOutputStream() has already been called for this response
當使用鉻瀏覽器,然後圖像數據不轉換圖像格式和以上大廈錯誤發生。如何爲每個瀏覽器解決這個問題。