Dear all,
I have a BLOB field in a database which stored image in various formats
(JPG, GIF). When I try to write the file through the HTTP Response it always
fails. However, I successfully wrote it to a file so I assumed that my data
is valid (not corrupted). The followings is the scriptlet. Can anyone give
me a suggestion? Thanks a lot in advance.
Regards,
Erwin Kodiat
Mitrais Software Development Center
Bali, Indonesia
<%
try {
BinObject bo = new BinObject();
bo.objectID= "991986";
bo.type="test";
bo.contentType = "image/jpeg";
InitialContext ic = new InitialContext();
Object obj = ic.lookup("BinObjectBean");
BinObjectHome home = (BinObjectHome) PortableRemoteObject.narrow(obj,
BinObjectHome.class);
BinObjectRemote remote = home.findByPrimaryKey((PKBinObject) bo);
BinObject objBO = remote.getRepository();
response.setContentType("image/jpeg");
//BEGINNING OF SECTION TO DISPLAY IMAGE
OutputStream fos = null;
fos = response.getOutputStream();
fos.write(objBO.binaryData, 0, objBO.binaryData.length);
fos.flush();
fos.close();
}
catch(Exception e) {
System.out.println("JSP Error : "+ e.getMessage());
}
%>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets