How to display the image from db blob data type
How to display the image from db blob data type
PreparedStatement ps = con.prepareStatement("select sixfourdata from images");
ResultSet rs = ps.executeQuery();
rs.next();
Blob b = rs.getBlob("sixfourdata");
// How to display the image from MySQL blob data type
// Note sixfourdata is a blob data type.
?
?
[361 byte] By [
ElayaRajaa] at [2007-11-27 10:47:43]

You need to write a servlet. This needs to set the content type to the appropriate MIME type (according to the image format you are using).
Then open an InputStream from the Blob and copy it to the outputStream from the response with a simply buffer and loop.
This servlet is invoked from an IMG tag.
You can't, directly. JSP will generate an HTML page. You can use it to generate an HTML page with the <IMG tag which displays the image. But the image must be retrieved by a separate transaction. The src attribute in the IMG tag must reference a servlet's URL to retrieve the image data.
JSPs are for generating HTML, anything else (like image and other formats) you need a servlet.
Sorry, but you can't get away with using JSPs for everything.>