• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

display image from bytearray

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i am trying to convert a byte array of image into image and want to display in JSP page. i am able to save the picture in any location but cant display it in the web page.

here is my code

byte[] decoded = //the decoded base64 string in bytes.

BufferedImage bufferedImage = ImageIO.read(new ByteArrayInputStream(decoded));
File imageFile = new File("E:/profile.jpg");
ImageIO.write(bufferedImage,"jpg", imageFile);

this is working fine... the image gets store in the given location. but when i pass it through outputstream, it does not print it in the JSP page.

byte[] decoded = //the decoded base64 string in bytes.

BufferedImage bufferedImage = ImageIO.read(new ByteArrayInputStream(decoded));
OutputStream out = response.getOutputStream();
ImageIO.write(bufferedImage, "jpg", out);
out.flush();
out.close();

how can i print it in a new jsp file.....

please help...
thank you...

 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly how does the IMG tag in the HTML written by the JSP refer to the image source?

Bill
 
nikki sinha
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

William Brogden wrote:Exactly how does the IMG tag in the HTML written by the JSP refer to the image source?

Bill



i am a little confused about this... but what i did is using the url pattern of the servlet given in the web.xml


userimage is my servlet
if i am wrong then please correct me
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whatever image you tried to paste into your post is not showing in my browser. It is much more useful to cut and paste the actual text from web.xml - kindly use the "code" tags.

Also kindly show the exact URL as you have formulated it in the HTML written by your JSP - use your browser's "view source" capability to get the exact text.

Bill
 
    Bookmark Topic Watch Topic
  • New Topic