Привет, ребята, мой код упоминается, когда я запускаю код на сервере, однако он выполняется и не показывает никаких ошибок, но я не могу получить изображение в браузере, или изображение не отображается, оно показывает черный бланк .. .. не могли бы вы помочь мне решить эту проблему? Пожалуйста, поделитесь своим комментарием
<body>
<%
ResultSet rs = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Connection connection = null;
Statement statement = null;
Blob image1 = null;
Blob image2 = null;
Blob image3 = null;
Blob image4 = null;
Blob image5 = null;
byte[ ] imgData = null ;
OutputStream o=null;
%>
<h2 align="center">
<font><strong>Retrieve data from database in jsp</strong></font>
</h2>
<table align="center" cellpadding="5" cellspacing="5" border="1">
<tr bgcolor="#A52A2A">
<td><b>First</b></td>
<td><b>Second</b></td>
<td><b>Third</b></td>
<td><b>Fourth</b></td>
<td><b>Fifth</b></td>
<td>
</tr>
<%
try{
connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","SYSTEM","system");
statement=connection.createStatement();
String sql ="SELECT image1,image2,image3,image4,image5 from testimage";
rs = statement.executeQuery(sql);
while (rs.next()) {
image1 = rs.getBlob(1);
imgData = image1.getBytes(1,(int)image1.length());
image2 = rs.getBlob(2);
imgData = image2.getBytes(2,(int)image2.length());
image3 = rs.getBlob(3);
imgData = image3.getBytes(3,(int)image3.length());
image4 = rs.getBlob(4);
imgData = image4.getBytes(4,(int)image4.length());
image5 = rs.getBlob(5);
imgData = image5.getBytes(5,(int)image5.length());
}
// display the image
response.setContentType("image/jpg");
o = response.getOutputStream();
o.write(imgData);
o.flush();
o.close();
}
catch (Exception e) {
out.println("Unable To Display image");
out.println("Image Display Error=" + e.getMessage());
return;
} finally {
try {
//rs.close();
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
}
%>
<tr bgcolor="green">
<td><%=rs.getBlob("image1") %></td>
<td><%=rs.getBlob("image2") %></td>
<td><%=rs.getBlob("image3") %></td>
<td><%=rs.getBlob("image4") %></td>
<td><%=rs.getBlob("image5") %></td>
</tr>
</table>
</body>
JSP_ORACLE_ APACHE