I've problems displaying images in my index.xhtml file.
I want the link from my database to point to the image file so that a <h:graphicImage/>
or <img />
tag can display it. Currently using localhost only.
I've managed to save an image to c:\var\webapp\images\ and also added <property name="alternatedocroot1" value="from=/images/* dir=/var/webapp" />
to my glassfish-web.xml and using:
<h:graphicImage value="#{entity.imageLink}" />
<img alt="#{entity.title}" src="#{entity.imageLink}" />
But I never manage to display any images! What should be written in my database to display imageExample.jpg which is saved in c:\var\webapp\images\imageExample.jpg? My thought is that the problem lies in my path but I might very well be wrong.
Changed<property name="alternatedocroot1" value="from=/images/* dir=/var/webapp" />
to<property name="alternatedocroot_1" value="from=/images/* dir=c:\var\webapp" />
Notice the slashes.
In my database (MySQL) I save /images/imageExample.jpg
which then will be displayed with <h:graphicImage value="#{entity.imageLink}" />
.
I can now access the image at http://localhost:8080/<MyAppName>/images/imageExample.jpg
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With