Forums Register Login

DIsplaying Image on JSP

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
You can try something like



[ July 11, 2006: Message edited by: ak pillai ]
+Pie Number of slices to send: Send
 

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?
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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!
+Pie Number of slices to send: Send
What are you planning on doing with the data once you get it to the JSP?
+Pie Number of slices to send: Send
Display it as an image. Not sure if any conversions are needed?
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Thanks alot man! Its up and running
+Pie Number of slices to send: Send
Problem solved thx to Bear Bibeault and ak again.

I announce thread closed
Hot dog! An advertiser loves us THIS much:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 3632 times.
Similar Threads
Display image in JSP
OutputStream an image within struts2 action class got error - Response already committed
Displaying images on JSP page
thumbnail in jsp
How Display image in a JSP that retrieved from a database?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:30:26.