please can anyone help me I? here is my code to load image from mysql and display it in jsp
<%@ page import="java.sq l.*"%>
<%@ page import="java.io .*"%>
<% Blob image = null;
Connection con = null;
byte[ ] imgData = null ;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName(" com.mysql.jdbc. Driver");
con = DriverManager.g etConnection("j dbc:mysql://localhost/television","ro ot","timo");
stmt = con.createState ment();
rs = stmt.executeQue ry("select passport from remote where id = '4'");
if (rs.next()) {
imgData = rs.getBytes(1);
} else {
out.println("Di splay Blob Example");
out.println("im age not found for given id>");
return;
}
// display the image
response.setCon tentType("image/gif");
OutputStream o = response.getOut putStream();
o.write(imgData );
o.flush();
o.close();
} catch (Exception e) {
out.println("Un able To Display image");
out.println("Im age Display Error=" + e.getMessage()) ;
return;
} finally {
try {
rs.close();
stmt.close();
con.close();
} catch (SQLException e) {
e.printStackTra ce();
}
}
%>
but it's still given me error:
The Image "http://WebApplication/index.jsp" cannot be display because it contains error. I can precisely identify this error.
<%@ page import="java.sq l.*"%>
<%@ page import="java.io .*"%>
<% Blob image = null;
Connection con = null;
byte[ ] imgData = null ;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName(" com.mysql.jdbc. Driver");
con = DriverManager.g etConnection("j dbc:mysql://localhost/television","ro ot","timo");
stmt = con.createState ment();
rs = stmt.executeQue ry("select passport from remote where id = '4'");
if (rs.next()) {
imgData = rs.getBytes(1);
} else {
out.println("Di splay Blob Example");
out.println("im age not found for given id>");
return;
}
// display the image
response.setCon tentType("image/gif");
OutputStream o = response.getOut putStream();
o.write(imgData );
o.flush();
o.close();
} catch (Exception e) {
out.println("Un able To Display image");
out.println("Im age Display Error=" + e.getMessage()) ;
return;
} finally {
try {
rs.close();
stmt.close();
con.close();
} catch (SQLException e) {
e.printStackTra ce();
}
}
%>
but it's still given me error:
The Image "http://WebApplication/index.jsp" cannot be display because it contains error. I can precisely identify this error.