File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Available Tag for rendering image using bytes array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Available Tag for rendering image using bytes array" Watch "Available Tag for rendering image using bytes array" New topic
Author

Available Tag for rendering image using bytes array

mini mehta
Ranch Hand

Joined: Oct 22, 2000
Posts: 120
Hi

Does any body know of any custom tag for rendering image using a byte[]

i,e something like

<imagetag image="<%=form.getBytes() %>" height="<%form.getHeight() %>" width="<%form.getWidth() %>" />

Mini
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60817
    
  65

No. And there could never be one. That's not the way HTTP works.

You would use a normal img tag and specify the src to point to the URL of a servlet that would serve up the image data.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
mini mehta
Ranch Hand

Joined: Oct 22, 2000
Posts: 120
I have already done that by creating a Image Servlet. But what i don't understand is why can't u do it through a tag. When you can have a iterator tag which accepts a Collection object, then you can always accept a byte array too.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60817
    
  65

Originally posted by mini mehta:
But what i don't understand is why can't u do it through a tag.


Because HTML doesn't work that way. There is no meand to put the byte data directly into an HTML page and then expect theimage to show up. You must make a spearate request through an <img> tag.

JSP isn't any kind of magic that will make HTML do anything it can't do outside of JSP.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60817
    
  65

Oh, and please read this with regards to using words like "u". Thanks.
mini mehta
Ranch Hand

Joined: Oct 22, 2000
Posts: 120
Originally posted by Bear Bibeault:


Because HTML doesn't work that way. There is no meand to put the byte data directly into an HTML page and then expect theimage to show up. You must make a spearate request through an <img> tag.

JSP isn't any kind of magic that will make HTML do anything it can't do outside of JSP.


I never said html img will do it. I mean writing a custom jsp which has access to every object as servlet like OutputStream.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60817
    
  65

Still can't do it. JSP is a templating technology used to render HTML pages to be sent to the client. You cannot do anything with JSP that HTML cannot do. And HTML cannot render images with a byte stream embedded in a page.
 
Consider Paul's rocket mass heater.
 
subject: Available Tag for rendering image using bytes array
 
Similar Threads
how to retrieve image from temporary using ajax
Refresh dynamic tree in tapestry
Question about html:image tag
Retreiving a image from a database using servlet
JTextPane -captured image refreshing problem