why dont you try like this:
i have a getImageDetails.jsp to retrive the image data from the database based on user_id or name or some other constraint as follows (put the code in jsp/servlet page)
int img_id = Integer.parseInt(request.getParameter("your_id"));
Connection con = //get your connection object here ;
ResultSet rs = null;
PreparedStatement pstmt = null;
OutputStream oImage;
try {
pstmt = con.prepareStatement("your sql statement for retriving the image column data");
pstmt.setInt(1, img_id);
rs = pstmt.executeQuery();
if(rs.next()) {
byte barray[] = rs.getBytes(1);
response.setContentType("image/gif");
oImage=response.getOutputStream();
oImage.write(barray);
oImage.flush();
oImage.close();
}
}
catch(Exception ex){
//ex.printStackTrace();
}finally {
try{
if(con!=null)
con.close();
}catch(Exception ex){
// ex.printStackTrace();
}
}
then i am calling this page from html or any another jsp page as follows
< img src="getImageDetails.jsp?your_id=12" width="50" height="50" />
please try like this you will get answer
let me know the status
happy coding