File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Displaying byte array as image using javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Displaying byte array as image using javascript" Watch "Displaying byte array as image using javascript" New topic

Displaying byte array as image using javascript

vamshi gurudu

Joined: Sep 23, 2008
Posts: 21

I want display byte array in to image using java script, any help.

Actually i am inserting image in to mysql database using blob, image is converted to byte array.
I am retrieving all the table values using json array and displaying using javascript, in the json array i am adding this image byte array also.
I am able to retrieve the other values, but not able to display this byte array as image.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63838

The byte array is useless on the page. You'll need to create an image tag and have it reference a servlet that returns the image data as it's response.

[Asking smart questions] [About Bear] [Books by Bear]
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
If you want to make this work in all browsers, you need to have the server return the image.

You can always set the src of the image with a get request that can retrieve the image from the database

I agree. Here's the link:
subject: Displaying byte array as image using javascript
It's not a secret anymore!