• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Iterator doesn't show picture

 
Honzak Troubak
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<s:iterator> is not a standard JSP tag. You must be using a framework. Which?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts 2.3.4 and for persistence I'm using Hibernate 4.1.6
 
Honzak Troubak
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how i wrote, i tried us <img src="<s:property value="image"/>"> but it doesn't work
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand you, you want to see my html code.

From


Is this <img src="[B@a5e9a9">
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys, i resolved this problem - i didn't use iterator.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic