title: How to get local file in HTML when using JSP and Java
body: <p>I'm running a Java web application using Tomcat and I've got my Java classes and .jsp files rendering the web. I am trying to implement a feature where you search for key words within files and then return the files so the user can download them from the webpage.</p>
  
  <p>I want to store the files within a local directory, as the server will eventually be running off a local Linux machine. However, I am unable to get the path to the file to work on the HTML side. In Java I can easily do :</p>
  
  <pre><code>final File file = new File("/home/user/resources");
  </code></pre>
  
  <p>Which will find the files in there. However, in HTML I've been trying various URL's, including:</p>
  
  <pre><code>a href="/home/user/resource" download&gt;"Name"&lt;/a&gt;
  </code></pre>
  
  <p>However it cannot find the file, I gather this is because it's looking within the web application. </p>
  
  <p>So, my question is. How can I get the HTML side to find the same files, in the same location as Java? If it's not possible without storing the files within the web app, is there a way to serve up the file from the Java side and make it available to HTML?</p>
  
  <p>Also, the files I'll be storing will most likely be Word files, .doc and .docx.</p>
  
  <p>Thanks for your help in advance.</p>
  
  <p>Let me know if you need any more info.</p>
  
  <p>EDIT : Updated download link within the .jsp file and within &lt;% %> tags.</p>
  
  <pre><code>&lt;a href="file:///home/simon/resources/clientInfo/" + entry.getValue() + "\" download&gt;" + entry.getValue() + "&lt;/a&gt;
  </code></pre>
  
  <p>Chrome complains of a network error.</p>