k.elgohary
k.elgohary

Reputation: 443

Display image from external location by jsf

I read number of posts about the same issue and the solution from the "tomcat server" side is to add element inside element and what i did like this :

<Host>
    <Context docBase="path_to_image" path="/images" />
.....

My issue now is that if i tried to display the image by html image tag like that :

<img src="/images/dist/image_name.ext"/>

the image rendered without any problem , but i have aproblem when use the jsf tag like :

<h:graphicImage value="/images/dist/image_name.ext" />

this tag's output is : [http://localhost:8080/context_name/faces/images/dist/image_name.ext]

so i think if i can point to [http://localhost:8080/images/dist/image_name.ext] from the jsf component it will solve the issue but how can i make this ?

Any idea ?

I see this article http://balusc.blogspot.com/2007/04/imageservlet.html

but it will be betterif i can solve that issue by the server.xml as i mentioned before .

Upvotes: 0

Views: 1774

Answers (1)

BalusC
BalusC

Reputation: 1108632

The <h:graphicImage> will indeed implicitly prepend the webapp context path to image's URL. Just don't use it and stick to plain HTML <img> element. Whatever reason you've in mind which would require it to be a <h:graphicImage> component needs to be reconsidered or solved differently so that you can keep using plain HTML <img>. element.

Upvotes: 2

Related Questions