• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to convert blob data to image and display

 
vijay jamadade
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I have stored a pdf file in database as a blob data type. I am getting it through query. I have a search result page where
i want to provide a link to view the image of this pdf data. Please tell me how to convert the blob data to the image content
in servlet. and set it in response.

Sorry i dont know in which section my question will fit. Please move to the proper section if so.

Thanks in advance.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just get an InputStream of it using ResultSet#getBinaryStream() and then write it to the OutputStream of the HttpServletResponse.

DonĀ“t forget to set the important response headers accordingly. At least the content-type, content-disposition and content-length.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic