wood burning stoves 2.0*
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: 60782

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] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
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

Consider Paul's rocket mass heater.
subject: Displaying byte array as image using javascript
Similar Threads
displaying byte array as image in IE
forwarding to servlet
Mime type in JSP
displaying pdf image