title: problem in accessing contents of the file using javascript with tomcat
body: <p>The following code is inside <code>&lt;script&gt;</code> tag of <code>index.html</code> of my application and it works fine (basically the code is inside a function which gets called when a user clicks on a download button from the UI;the files are already present on the server/location mentioned below) when I access my app via web browser in the following manner:</p>
  
  <pre><code>file:///C:/jack/testing/ui/static/index.html
  </code></pre>
  
  <p>By works, I mean, I can see the 3 files getting downloaded in csv format with 3KB of size.</p>
  
  <pre><code>const requests = [
    'file1_1555077233.csv',
    'file2_1555077233.csv',
    'file3_1555077233.csv'
  ].map(file =&gt; {
    return fetch('file:///C:/jack/file/JACK/' + file)
      .then(response =&gt; response.text())
      .catch(console.error)
  })
  
  Promise.all(requests)
    .then(contents =&gt; {
      const zip = new JSZip()
  
      contents.forEach((content, index) =&gt; {
        zip.file(`file-${index}.csv`, content)
      })
  
      return zip.generateAsync({ type: 'blob' })
    })
    .then(blob =&gt; {
      saveAs(blob, 'files.zip')
    })
  </code></pre>
  
  <p><strong>Scenario 1:</strong></p>
  
  <p>However, when I have my application deployed as WAR file in tomcat, I access my application in the following manner from the web browser :</p>
  
  <pre><code> http://localhost:8080/testing/index.html
  </code></pre>
  
  <p>In this scenario, the above javascript doesn't completely work. I mean, it downloads the 3 files but the size of the file is empty. This makes sense since I am accessing the website over HTTP and my files 
    should be served by the server. </p>
  
  <p>On windows, how should I modify this line of code <code>return fetch('file:///C:/jack/file/JACK/' + file)</code> so that it starts working in this scenario. </p>
  
  <p><strong>Scenario 2:</strong></p>
  
  <p>Similarly, when I deployed the WAR in the tomcat running on RHEL server, I am accessing my application in the following manner: </p>
  
  <pre><code>https://myserver.com/testing/index/html 
  </code></pre>
  
  <p>In this scenario also, I am noticing empty files are getting downloaded when I used the above code with this change: </p>
  
  <pre><code>  return fetch('/srv/users/JACK' + file)
  </code></pre>
  
  <p><code>Scenario #1</code> is just used for my local testing and it's okay if it doesn't work for me because I can understand that I may not be able to access the files from my local directory. However, in <code>Scenario 2</code>, on RHEL server, I am trying to access the files from <code>srv/users/JACK</code> directory which isn't local or specific to any user. Why I am still seeing 3 empty csv files getting downloaded in this scenario? Please advise what would be best course of action to overcome this scenario.</p>