| Author |
Display of images in JSP
|
Shrikant Kulkarni
Ranch Hand
Joined: May 10, 2005
Posts: 42
|
|
Hi, I am new to handling of BLOB objects. i want to display all the images present in a particular table for a particular ID: The sql query is as below select image from image_upload where log_id=? Note: image is BLOB type In jsp: I get a ResultSet (rs): <% while(rs.next()) { InputStream inputStr = rs.getBinaryStream(1); byte[] bytearray = new byte[4096]; ByteArrayOutputStream outStream = new ByteArrayOutputStream(); int nbytes = 0; // Number of bytes read while( (nbytes = inputStr.read(bytearray)) != -1 ) { outStream.write(bytearray, 0, nbytes); } outStream .close(); inputStr.close(); %> <tr> <td valign = "baseline"> <img align = "bottom" src = "<%=imageName%>" alt="<%=imageName%>" height="100" width="100"/> </td> </tr> But in JSP page it displayed a broken image link, not the image which i got it from database. Can any one please tell me what piece of code i should write in order to display all the images??
|
 |
Carl Trusiak
Sheriff
Joined: Jun 13, 2000
Posts: 3340
|
|
|
You are a little confused on how images are processed in a displayed page in a browser. Each image is seperately loaded by the browser using a new request to the server. Therefore, you need to have a send server process to handle the image. I would suggest a servlet for that.
|
I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
|
 |
 |
|
|
subject: Display of images in JSP
|
|
|