aspose file tools*
The moose likes JSF and the fly likes How to render image in facelet from external location? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to render image in facelet from external location?" Watch "How to render image in facelet from external location?" New topic
Author

How to render image in facelet from external location?

Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

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!


True person is moral, false is right!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16222
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

I have resolved this issue easily with help of this article - http://balusc.blogspot.com/2007/04/imageservlet.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to render image in facelet from external location?