aspose file tools*
The moose likes Servlets and the fly likes How to convert blob data to image and display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to convert blob data to image and display" Watch "How to convert blob data to image and display" New topic
Author

How to convert blob data to image and display

vijay jamadade
Ranch Hand

Joined: May 12, 2008
Posts: 240
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.


Regards, Vijay Jamadade.
( Nothing is Impossible.)
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
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.
 
Consider Paul's rocket mass heater.
 
subject: How to convert blob data to image and display