Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should GlassFish alternatedocroot path be to display an image in h:graphicImage?

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.

like image 208
TheZeph Avatar asked Nov 10 '22 11:11

TheZeph


1 Answers

Solved this as follows:

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.

like image 129
TheZeph Avatar answered Nov 15 '22 10:11

TheZeph