reading byte image from database in servlet and displaying it in jsp page
Hi experts,
I have saved my image data in the my database (ms sql server 2000).
Now I am reading in the bytes from the database in ejb. I am access this in a servlet. Now I want access this in my jsp page. How can I do this.
Heres my servlet code:
response.setContentType("image/jpeg");
response.setHeader("pragma", "no-cache");
ServletOutputStream out = response.getOutputStream();
out.write(content.getContentObj());
out.close();
Please help me.
Thanx...
Deepak
# 3
Represent each and every image stored inside the db by a unique imageid and while querying use imageid and retrive appropriate Blob field. and here is how you call an image servlet while gives you image reponse.
<table>
<tr>
<td><image src="ImageServlet?imageid=1"/></td>
<td><image src="ImageServlet?imageid=2"/></td>
<td><image src="ImageServlet?imageid=3"/></td>
</tr>
<tr>
<td><image src="ImageServlet?imageid=4"/></td>
..................................
..................................
</tr>
</table>
Hope that might help :)
REGARDS,
RaHuL
# 6
You can reuse the code, but just replace the contentdisposition 'inline' by 'attachment'. Also see the several downloadFile() snippets at the bottom of this article: http://balusc.xs4all.nl/srv/dev-jep-pdf.html Use this in kind of a FileServlet, which can be created and used almost the same way as ImageServlet.
# 9
Hi guys, Actually i want to upload a image file and save it into a mysql db,using jsp. And i want to open the image in browser(retreving img from db).If u have any idea, plz reply this topic.