File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply 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: 224
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.


Code depot of a Java EE / JSF developer | JSF / Eclipse / Tomcat kickoff tutorial | DAO kickoff tutorial | I ♥ Unicode
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to convert blob data to image and display
 
Similar Threads
How do I insert a BLOB from a servlet
uploading images using strut
How do I insert an image into a database from a servlet?
Converting Blob to word
Convert XML data stored in a BLOB column in database back to XML format