Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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.
 
    Bookmark Topic Watch Topic
  • New Topic