very thx to Jules,I have already figured out this problem with your help.
now I post my complete JSP code ,hope can help others.
<%@ page contentType="text/html; charset=ISO-8859-1" %>
<%@ page import="java.sql.*,java.io.*"%>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc
dbc:testforwebsphere","sa","sa");
String sql = "select * from testforphoto where test='111'";
PreparedStatement pstmt = conn.prepareStatement(sql);
ResultSet rs =pstmt.executeQuery();
rs.next();
InputStream in = rs.getBinaryStream("photo");
OutputStream sos = response.getOutputStream();
int len = 0;
byte[] b = new byte[1024];
response.reset();
response.setContentType("image/gif");
while((len = in.read(b)) > 0)
sos.write(b);
in.close();
sos.close();
%>
<html>
<body>
show the picture successfully!
</body>
</html>
Originally posted by Julian Kennedy:
So, is your question how to read a Blob type from a database? If you look at the thread I linked to, that may help you. If you give it a bit of thought you can easily adapt my example to work for you.