1

Firs of all I have already tried this: Load images from outside of webapps / webcontext / deploy folder using <h:graphicImage> or <img> tag

But I have not archived what I wanted yet. This is my case:

I have a Java Web Application using NetBeans 8.0, JSF, PrimeFaces and Glassfish (all in Windows 7) everything installed in C:

And i create QR codes and store them in these paths:

  1. The static path: C:\ImagenesAlmacen\QR

  2. The server path: C:\Users\Win\AppData\Roaming\NetBeans\8.0\config\GF_4.0\domain1\config\QR

I used this code to get the server path:

(QR is a directory that i created there and this.idRefaccion+".png"; is the name of the image)

 String rutaImagen = new File("").getAbsolutePath()+"\\QR\\"+this.idRefaccion+".png";

First of all i want to know if that really is the server path. I dont remmember where i got that code but they said that that was the way to get the server path.

So the info of the first line link says

Option1:

Just drop the folder with all images, e.g. /images directly in servletcontainer's deploy folder

Where is that folder in my case? in the /domains/domain1/applications i have a directory named: _internal

This is the path to that:

C:\Users\Win\AppData\Roaming\NetBeans\8.0\config\GF_4.0\domain1\applications\_internal

and inside there there is another directory named as my Project but there is nothing inside. I have already tried to put the folder with all images (in my case: QR) in the applications, _internal and the other folder.

Nothing worked for me...

Option 2:

Add a new <Context> to the servletcontainer with a docBase which points to the absolute disk file system location of the folder with those images. How to do that depends on the container used. In case of for example Tomcat, that'll be the following new entry in /conf/server.xml:

<Context docBase="/path/to/images" path="/images" />

In case of for example Glassfish, that'll be the following entry in glassfish-web.xml:

<property name="alternatedocroot_1" value="from=/images/* dir=/path/to" />

And I tried that like this:

In my web.xml I added (for the static path):

<context-param>
    <param-name>alternatedocroot_1</param-name>
    <param-value>from=/QR/* dir=/ImagenesAlmacen</param-value>
</context-param>

Did not work for me...

This is the code in the view:

<h:graphicImage value="/QR/H_1.png" />

So please let me know what am I doing wrong. And thanks for any clue You can give me And remember I need to get those images from the static path and the server path ;)

Community
  • 1
  • 1
Kaz Miller
  • 949
  • 3
  • 22
  • 40

0 Answers0