What should be the GlassFish alternatedocroot path for displaying the image in h: graphicImage?

I am having problems displaying images in my index.xhtml file.

I want the link from my database to point to an image file so that the <h:graphicImage/> or <img /> can display it. Currently only the local host is used.

I managed to save the image in c: \ var \ webapp \ images \, and also add <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 is in my way, but I could very well be wrong.

+5
source share
2 answers

Solved the following:

Changed
<property name="alternatedocroot1" value="from=/images/* dir=/var/webapp" />
before
<property name="alternatedocroot_1" value="from=/images/* dir=c:\var\webapp" />
Pay attention to slashes.

In my database (MySQL) I save /images/imageExample.jpg , which will then be displayed using <h:graphicImage value="#{entity.imageLink}" /> .

Now I can access the image at http://localhost:8080/<MyAppName>/images/imageExample.jpg .

+1
source

There is always a good idea when in doubt, print in the server log to find out what you are passing in the tag, but I think the problem is that when using the backslash it should be doubled \, since it is used to exit characters .

0
source

All Articles