File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

display image from bytearray

 
nikki sinha
Greenhorn
Posts: 14
  • 0
  • 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...

 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13047
6
  • 0
  • 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
  • 0
  • 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
Rancher
Posts: 13047
6
  • 0
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic