File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Display byte[] in browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Display byte[] in browser" Watch "Display byte[] in browser" New topic

Display byte[] in browser

Subha Rangu

Joined: Jul 23, 2004
Posts: 29
I have a Java program which retrieves a TIFF Document/Image in byte[] format. Can anybody tell what has to be used inorder to see my image on the browser from a jsp/Java code.
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
I'm guessing now, but have you tried setting the contentType to "image/tiff" and just writing the byte[] to the response?

Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
OutputStream out = response.getOutputStream();
// write the byte[] to 'out'

Tony Morris
Java Q&A (FAQ, Trivia)
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
You may also have to set the Content-length to make the browser happy.
Subha Rangu

Joined: Jul 23, 2004
Posts: 29
Hi Tony and Julian,
Thank you very much for all the help. I got stuck up with this problem the whole day yesterday. I could solve it now. I will be really thankful to you guys...
I agree. Here's the link:
subject: Display byte[] in browser
jQuery in Action, 3rd edition