jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes How to display image on browser from byte array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to display image on browser from byte array" Watch "How to display image on browser from byte array" New topic
Author

How to display image on browser from byte array

kumar sivaramakrishnan
Greenhorn

Joined: Apr 09, 2008
Posts: 4
I am using an api in a web app to return a byte array of an image stored in a database. I have tried dumping the byte array into the response but the browser does not display it. Believe the image is a tiff so I also tried downloading the tiff browser plugin. Still does not work.

What is the best way to do this?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Most browsers don't display tiff without the aid of plugins.
You might want to test with the browsers you plan to support by trying to serve up a static tiff file using a plain old <img /> tag before going too far with this..


In our CodeBarn, in the servlets section, there is a sample app, packaged in a war file that streams images to browsers. Look for SimpleStream. In that app, the images are read from disk using context.getResourceAsStream. You'll need to modify it to serve up your byte array or, (if your library can serve one) a stream. It should be enough to get you going though.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to display image on browser from byte array
 
Similar Threads
DIsplaying Image on JSP
Problem Sending Tiff Image in Servlet response
Refreshing an embedded object
Why don't running the applet developping the JAI package&#65311;
Display byte[] in browser