I am using BLOB's wiht CMP's. The CMP maps the BLOB to
a byte array. My DTO has the following properties.
private String name;
private byte[] poster;
Is there a way to directly display this in a datatable wihtout first saving it in a .gif file and then
displaying it as a graphic image in JSF's or is there a better way to do it.
-
Best way to use BLOB's in JSF's (1 messages)
- Posted by: Dev Anand
- Posted on: June 13 2005 05:25 EDT
Threaded Messages (1)
- Blob in JSF by Naveen Sisupalan on November 24 2008 17:56 EST
-
Blob in JSF[ Go to top ]
- Posted by: Naveen Sisupalan
- Posted on: November 24 2008 17:56 EST
- in response to Dev Anand
I don't think we can use byte[] array to show images in JSF. But there is a way to avoid that temporary image file. What you have to do is create a servlet, which will read the blob and write to the ServletOutputStream. Then in your JSF page put an iframe, where you want to show the image. src attribute of this iframe will point to ImageServlet. You JSF page will look like: ImageServlet's doGet method will be like: res.setContentType("image/gif"); ServletOutputStream out = res.getOutputStream(); dao = new EmployeeImageDAO(); dao.openConnection(); InputStream in = dao.getEmployeeImageStream(Integer.parseInt(empId)); byte[] buffer = new byte[in.available()]; while(in.read(buffer) != -1) { out.write(buffer); } out.flush();