• 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

DIsplaying Image on JSP

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
I am currently trying to display an image that was converted from byte array in the servlet and then push it and display in the jsp site. Does anyone have any idea how to do this?

Thanks in advance for helping
 
author
Posts: 288
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can try something like



[ July 11, 2006: Message edited by: ak pillai ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Yans Tan:

I am currently trying to display an image that was converted from byte array in the servlet and then push it and display in the jsp site. Does anyone have any idea how to do this?



Remember, once it gets to the browser, a JSP page is just like any other normal HTML page.

So if you wanted to display an image in an HTML page, how would you do it?
 
Yans Tan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:


Remember, once it gets to the browser, a JSP page is just like any other normal HTML page.

So if you wanted to display an image in an HTML page, how would you do it?



Hi there, thx for the advice. I think I have to apologise for giving a bad title to my post. I think the problem I am facing now is more of how to send the data over to JSP rather than displaying it.
 
Yans Tan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there, sorry to trouble you guys again. I think my english is bad, sorry about it. I think i should list out what I am doing in point form, hope this helps

1) Servlet recieves XML info containing Base64 of the image.
2) Servlet interpretes XML and converts Base64 to byte array.
3) Servlet sends byte array through http response to JSP<< This is the part which i faced my problem.

Thx again for all the troubles!
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are you planning on doing with the data once you get it to the JSP?
 
Yans Tan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Display it as an image. Not sure if any conversions are needed?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So we go back to my first question.

In a "normal" HTML file, you don't mix up the text markup and image data, do you?

Since JSP sends an HTML page to browser, how do you plan to display the image data in that HTML file?
 
Yans Tan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My original plan was to convert from
Base64 >> byte array >> Image object

But I do not know how to display it in JSP. So there is no solution to this? Thx again for all the follow ups
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It can be done, but not in the way you are planning.

On your JSP page -- which will turn into an HTML page when sent to the browser -- you need to create an <img> tag that references the URL of a servlet that will serve up the image data (along the lines of what ak posted earlier).

You can't just send image data along with the HTML markup.
 
Yans Tan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks alot man! Its up and running
 
Yans Tan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem solved thx to Bear Bibeault and ak again.

I announce thread closed
reply
    Bookmark Topic Watch Topic
  • New Topic