title: how to display images in Grails?
body: <p>I am trying to render the images from <code>/WEB-INF/images/sps</code> in the GSP page using the following code:</p>
  
  <pre><code>def index = {
      def baseFolder = grailsAttributes.getApplicationContext().getResource("/").getFile().toString()
      println baseFolder
      def imagesFolder = baseFolder + '/images/sps'
      println imagesFolder
      def imageList1 = new File(imagesFolder).list()
      println imageList1
      def imageList = Arrays.asList(imageList1)       
      println imageList
      imageList
      //redirect(action:"displayImages", params:["imageList":imageList])
      //render(view:"displayImages")
  }
  </code></pre>
  
  <p>The controller is able to read the images from the fileSystem. But when I try to display them using the following code, the images are not coming.</p>
  
  <p><strong>index.gsp</strong></p>
  
  <pre><code>&lt;g:each in="${imageList}" var="image"&gt;
     &lt;img src="${resource(dir: 'images', file: image.filename)}" alt="Grails"/&gt;
  &lt;/g:each&gt;
  </code></pre>
  
  <p>What mistake am I doing?</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>When I try with single image, it is working fine - I am able to view the image that is in the <code>WEB-INF/images</code> folder</p>
  
  <pre><code>&lt;img src="${resource(dir: 'images', file: '1.jpg')}" alt="Grails"/&gt;
  </code></pre>
  
  <p>And there is no HTML code thats getting generated for the loop code(above index.gsp code). Its just blank.</p>
  
  <p><em>My requirement is to display all the image files that are on the file system folder.</em></p>