• 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

How to make sense of my binary data

 
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, so I have managed to upload an image... It was written to a BinaryOutputStream and then written to a String object (following the struts sample). I think I have done this right only that, doing ${picture} outputs a set of ascii code such as


!1AQa?"Rq?��2B����#3CS?$4br�?��� ?��?��?� #���^?C�???@��?`�Cd��L �c�?� ����?�?��??�?�t&?~�?�?0 ct�"=�(T?B?@!@B??!!@B??!!@B??!!@B??!!@B??!!@B??!!@B?!PH�???A$� ?�e�H�?�@D��} ~�?�B?���I�G�?"|��G��G;$I��H�����I�?;n??L�|��?D?O��F�#?;?g�o�G�?PF�T) ?N�7<�Qpo?Dq??�vI�jG���N{&2w�h��.��*J?�?�o�i{? ?�1�`c���h��1�0?��?�??@l���Jc; o�a@G??I�T?:&?�B" B? ! ?B?? !BB?? !BB?? !BB?? !BB?? !BB?? !BB?? ! B ! ! BX??(QwH��4�??� %B??�R>??�I�*G��Q=w@.�'d��:y$R?�����I��D� $g�H�8?3��H��#��K�#�PA�?%D��G�#?�?(?��tQ;n�(?�Bx��h�"���L���H[��??�#



and what I really want is to use the uploaded file(binary data) into an image tag in one of my jsp's... How am I suppose to do this? Thanks!
[ May 31, 2006: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll need to store the binary data from the image somewhere (A file on the file system or cached in memory) and create an html image tag to something that will serve the image up. If you save it as a file , it can simply be the URL to the image. If you save it in memory, you'll need to have a servlet output the contents.
 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, thanks for your reply...


If you save it in memory, you'll need to have a servlet output the contents.




This is exactly what I need to do. I saw some samples on the internet but doesn't actually understand how they work... One thing for example, this code found at this page...





I understand how the other lines work... But I don't know how the image is sent back with the response... Here's another code which confuses me...





thank you...
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to write a simple servlet or JSP which sets content type to something like image/png and write your saved in memory or file image to servlet output stream. Access your image servlet from page using something like: <img src="/mycontext/myimageservlet?imageid=xxx">
You can look in example of a contact application in my signature. It allows to upload image (photo) and display it on page after.
 
reply
    Bookmark Topic Watch Topic
  • New Topic