P
palak123i
Hi,
We have a requirement to load (show on screen) several images stored
in oracle table as BLOB. I am using code as follows to load the
images:
In JSP:
<img src='<%=request.getContextPath()%>/getImage.do?giftCode=10
In Action class:
I read image from database a binary stream and flush the image as
outputstream.
String giftCode =
request.getParameter("giftCode");
InputStream sImage;
sImage = rs.getBinaryStream(1);
String imageType = rs.getString(2);
response.reset();
response.setContentType(imageType);
response.addHeader("Content-Disposition","filename=getimage");
while((size=sImage.read(bytearray))!= -1 )
{
response.getOutputStream().write(bytearray,0,size);
}
response.flushBuffer();
sImage.close();
The problem is that, some of the images are not loading and show up as
'X' on UI. This behavior is intermittent.
Can anyone suggest a better way of showing images from database to UI?
Or any improvements in above code?
Thanks,
Palak
We have a requirement to load (show on screen) several images stored
in oracle table as BLOB. I am using code as follows to load the
images:
In JSP:
<img src='<%=request.getContextPath()%>/getImage.do?giftCode=10
In Action class:
I read image from database a binary stream and flush the image as
outputstream.
String giftCode =
request.getParameter("giftCode");
InputStream sImage;
sImage = rs.getBinaryStream(1);
String imageType = rs.getString(2);
response.reset();
response.setContentType(imageType);
response.addHeader("Content-Disposition","filename=getimage");
while((size=sImage.read(bytearray))!= -1 )
{
response.getOutputStream().write(bytearray,0,size);
}
response.flushBuffer();
sImage.close();
The problem is that, some of the images are not loading and show up as
'X' on UI. This behavior is intermittent.
Can anyone suggest a better way of showing images from database to UI?
Or any improvements in above code?
Thanks,
Palak