• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Display image from the binary data in form of String in a JSP

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everybody,

I have a String with image in Base 64 encoded binary format. I would like to display the same in a JSP. Kindly guide me how to achieve this.

The string with data say

[ridiculously long Base64 string removed]

Kindly help me in achieving this
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. absolutely nothing was served by posting that whole monster string.
2. There is no reliable way to serve binary data from JSP, JSP assumes character data
3. each image on a HTML web page takes a separate request in an IMG tag
4. in a JSP you must create a URL for an IMG tag that points to a servlet which can serve the binary data with correct headers for type and content-length

Bill
 
binu narayanan
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill,

I just came across this piece of code for achieving what i had asked earlier

The value of the strImage is the monstrous value of the image in binary format.



Can you give an idea of how the servlet can help me get the image on the fly in a jsp

Thank you

Binu
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This Wikipedia article discusses the use of "data" in IMG tag URLs - apparently it is not universally supported so you risk failure for some users.

Bill
 
binu narayanan
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill,

Thanks for the info.

Could like to get a little bit of help in creating a servlet to render the base 64 encoded binary string.
 
I want my playground back. Here, I'll give you this tiny ad for it:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic