[Logo]
Forums Register Login
How to dispaly Blob (image) in servlet
So I got a Blob out of the MySql DataBase like:
if(rs.next()){
i = rs.getInt(1);
Blob b=rs.getBlob("img");


How do I show this in a servlet now?
I tried doing: response.setContentType("img/gif");
ServletOutputStream sout = response.getOutputStream();
sout.write(b);
sout.flush();
sout.close();

But It does not work. Please help.
 

Originally posted by Bikash Jha:
But It does not work.



This is not a useful description of the problem. How is it not working?

P.S. Check your MIME type.
Have you gone directly to the URL which accesses the servlet that outputs this? What do you see? Errors, or garbled nonsense? The mime type is ("img" ?) wrong that's for sure.
Here's an old, related post that may be of help:

http://www.coderanch.com/t/291337/JSP/java/Display-database-BLOB-jsp
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards


This thread has been viewed 2656 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jun 24, 2018 05:09:50.