Goal: Read a blob image from an Oracle database and render it on an html
page using the struts framework.
I've never found a good way to do this and I was hoping someone had a
"best practice" suggestion.
I have no trouble getting the image from the database. However, I wonder
if there isn't a better way to display it rather than writing it to a
physical file and then rendering it. I'm using the <html:img tag to
display the image now.
All help appreciated.
J.
ImputStream pictureStream;
ResultSet rs;
// create the query and execute it ...
// get the result
pictureStream = rs.getBinaryStream("picture");
// I can write it to a physical file
File pictureFile = new File("/temp/picture.jpg");
try
{
FileOutputStream out = new FileOutputStream(pictureFile);
int chunk = 0;
while( (chunk = pictureStream.read()) != -1)
{
out.write(chunk);
}
out.close();
out.flush();
}
catch(FileNotFoundException ex)
{
System.err.println("selectionForm.populate.picturefile: " +
ex.getMessage());
logger.error("selectionForm.populate.picturefile: " +
ex.getMessage());
}
catch(IOException ex)
{
System.err.println("selectionForm.populate.picturefile: " +
ex.getMessage());
logger.error("selectionForm.populate.picturefile: " +
ex.getMessage());
}
--
This transmission is intended only for use by the addressee(s) named herein and
may contain information that is proprietary, confidential and/or legally
privileged. If you are not the intended recipient, you are hereby notified that
any disclosure, copying, distribution, or use of the information contained
herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received
this transmission in error, please immediately contact the sender and destroy
the material in its entirety, whether in electronic or hard copy format. Thank
you.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]