• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic