• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DIsplaying Image on JSP

 
Yans Tan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • 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
 
ak pillai
author
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try something like



[ July 11, 2006: Message edited by: ak pillai ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Display it as an image. Not sure if any conversions are needed?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks alot man! Its up and running
 
Yans Tan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem solved thx to Bear Bibeault and ak again.

I announce thread closed
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic