jsfjava-ee-7contextpath

h:graphicimage value attribute: how to get path of server rather than webapp context root


I have configured wildfly to serve images from a certain context like this...

  <subsystem xmlns="urn:jboss:domain:undertow:1.0">
       <server name="default-server">
            <host name="default-host" alias="localhost">
                 <location name="/images" handler="book-images"/>
                 <!-- More config-->
            </host>
            <!-- More config-->
       </server>
       <handlers>
            <file name="book-images" path="/path/to/book/images" 
                  directory-listing="true"/>
            <!-- More config-->
       </handlers>
       <!-- More config-->
  </subsystem>

essentially, this makes it possible to access the files from wildfly at localhost:8080/images

i can access the images from the browser without a hitch e.g localhost:8080/images/009.jpg.

what i want is to be able to use these images in from a web app in img tags i.e

     <h:graphicImage value="/images/#{bookid}.jpg" />

but h:graphicimage adds the webapp context root so that src tags becomes /myapp/images/009.jpg.

my question is, how do i get the path of the server itself so that i can add /images/ to it and resolve the correct path? or how do i avoid the context root of the web app from being prepended to the path?


Solution

  • got an answer from BalusC fro another question (stick to plain img). check it here