aspose file tools*
The moose likes JSP and the fly likes Iterator doesn't show picture Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Iterator doesn Watch "Iterator doesn New topic
Author

Iterator doesn't show picture

Honzak Troubak
Ranch Hand

Joined: Jan 11, 2013
Posts: 31
Hello,

I want show picture via iterator but i don't know how. Could anybody help me? I have list which contains picture but I can't show that picture on JSP page.

Here is code:


When I use <s:property value="image"/> jsp page shows object (something like [B@5f3978) that's OK. But I need show object like picture. I need some like <img src="<s:property value="image"/>">. But that tag doesn't work.

Do anybody know any advice?

Thank you very much!

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

<s:iterator> is not a standard JSP tag. You must be using a framework. Which?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Regardless of the framework, what's going to end up at the browser is an HTML page. And in HTML pages, images are shown with the <img> tag. I do not see any <img> tags in your markup. How do you expect to show an image without one?
Honzak Troubak
Ranch Hand

Joined: Jan 11, 2013
Posts: 31
Struts 2.3.4 and for persistence I'm using Hibernate 4.1.6
Honzak Troubak
Ranch Hand

Joined: Jan 11, 2013
Posts: 31
how i wrote, i tried us <img src="<s:property value="image"/>"> but it doesn't work
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Honzak Troubak wrote:how i wrote, i tried us <img src="<s:property value="image"/>"> but it doesn't work


What does the src attribute end up containing? If it's the valid URL of the image, it will work. If not, the URL isn't correct.

Without telling us what the generated HTML ends up being, we can't help much because we have no idea what your markup is evaluating to.
Honzak Troubak
Ranch Hand

Joined: Jan 11, 2013
Posts: 31
If I understand you, you want to see my html code.

From


Is this <img src="[B@a5e9a9">
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Honzak Troubak wrote:Is this <img src="[B@a5e9a9">

Well, that's certainly not a valid URL for the image. What is the valid URL? You need to figure out how to make the src attribute the URL of the image.

What is the image property? Why are you using it as the image URL if it's not the image URL?

If it is, as I suspect, the image data, then you're doing it all wrong. You don't read image data and send it to a JSP. You reference the image by its URL using an <img> tag.
Honzak Troubak
Ranch Hand

Joined: Jan 11, 2013
Posts: 31
I already understand. I must from object get URL adress to server.

I hoped iterator have parameter something like "showObjectLikeImage". But that was bad idea.

I will to try get URL adress of object.

Thanks.
Honzak Troubak
Ranch Hand

Joined: Jan 11, 2013
Posts: 31
One more question - is possible use iterator when in list are objects from database? Because those objects doesn't have any URL or path (or i can't see it). I'm afraid it's only data in memory without URL or path.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

The URL should be to a servlet that streams the image data as the response. The servlet can get the data from the DB, or memory, or wherever it wants to.

Where the image data actually comes from is irrelevant to the image tag.
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2448
    
  28

Isn't there a way to embed base 64 encoded images right into HTML? I seem to remember that this was a new html5 feature but am kinda fuzzy about it.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

Browser support is too spotty, and it'd be a poor approach for caching, in my opinion. It's not an approach I would recommend, and certainly not one I would tell a novice to use.
Honzak Troubak
Ranch Hand

Joined: Jan 11, 2013
Posts: 31
Thank you guys, i resolved this problem - i didn't use iterator.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Iterator doesn't show picture