Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to render image in facelet from external location?

 
Volodymyr Lysenko
Ranch Hand
Posts: 511
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

I have tried almost everything I could in order to render simple image using h:graphicImage in template client.
My image is not inside war but on another location on the same disk. I upload through my webapp image.

Actually I don't have 'alt' attribute displayed or warning that image cannot be found. My image is found and probably is rendered BUT as empty frame with width and height I specified in h:graphicImage. This empty frame has color of background.

Does anybody know how to render image from outer location in facelet as I have not found example of this?

Thank you!
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18164
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the thing you're missing here is that connecting to a web server doesn't automatically give the client full access to the server's filesystem. In fact, since a web server is not a file server, you can't even access file shares via HTTP. The only data you can get via HTTP is data that the webapp has sent out in response to an HTTP request. So if you want to take files from a directory external to the WAR and present them as images, you have to provide a servlet that accepts a URL, parses it to determine what file (image) you want sent back, then opens that file and copies it to the response output stream. With the appropriate MIME encoding headers, of course.

In HTTP, all images on a web page are shipped from independent URL requests; the image data is not embedded in the primary response stream, only an HTML IMG tag that tells the client what URL to use to fetch the actual image. Whether that URL references the same webapp, some other webapp, or even an app on a machine on another continent makes no difference.
 
Volodymyr Lysenko
Ranch Hand
Posts: 511
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have resolved this issue easily with help of this article - http://balusc.blogspot.com/2007/04/imageservlet.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic