title: Relative path to image folder java spring
body: <p>I have a problem with a relative path to an image folder.
  I want to list the images into a folder to add their urls to a list and show them in a jsp.
  The code is this:</p>
  
  <pre><code>File carpetaImagenes = new File("../../../../../webapp/resources/img/maquinas/"+seleccion);
      List&lt;String&gt; listaUrlImagenes = new ArrayList&lt;String&gt;();  
  
      /** Recorremos el directorio de imagenes de la maquina */
      for(File imagen : carpetaImagenes.listFiles()){  
        String imageFileName = imagen.getName();          
        listaUrlImagenes.add(imageFileName);  
      }  
  </code></pre>
  
  <p>The result of "carpetaImagenes.listFiles()" is always null. I suppose the path is bad.
  Here you can see the image of the folder tree. The class is into "controlador" folder and the images are into "webbapp/resources/img/maquinas/1"
  <a href="https://i.stack.imgur.com/HO4vX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HO4vX.png" alt="enter image description here"></a></p>
  
  <p>I haeve tried several paths with no luck.
  Thank you very much.</p>