User the following piece of code to convert Blob to byte[]:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
InputStream in = blob.getBinaryStream();
int n = 0;
while ((n=in.read(buf))>=0)
{
baos.write(buf, 0, n);
}
in.close();
byte[] bytes = baos.toByteArray();
Use Servlet to write your image:
if (bytes != null && bytes.length > 0) {
response.setContentType("image/jpg");
response.getOutputStream().write(bytes);
response.getOutputStream().flush();
response.getOutputStream().close();
}
Use retrive your image using servlet request url in jsp:
<img src="imageDisplayProcess.do?pKey=imageId" width="117" height="160"
onError="loadImage()" onAbort="loadImage()" />
imageDisplayProcess.do?pKey=imageId //should be your image servlet URL