title: how to access a .js file from a .jsp file, residing in a different webapplication folder
body: <p>I have following situation:
  WebProject Structure:</p>
  
  <pre><code>- WebContent (Folder)
      - js (Folder)
          myfunctions.js (Javascript File)
      - jsps (folder)
          myjsp.jsp (JSP-File)
  </code></pre>
  
  <p>How do reference the javascriptfile (myfunctions.js) in my Java Server Page (myjsp.jsp) to be included ? Following doesn't work for me.</p>
  
  <pre><code>&lt;script type="text/javascript" src="../js/myfunctions.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>What I have done so far :</p>
  
  <p>I added a Servlet Mapping in <strong>web.xml</strong> to access static contents in Tomcat</p>
  
  <pre><code>  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;default&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/js/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>I can Access the file by direct requesting it:</p>
  
  <pre><code>http://localhost:8080/mycontextroot/js/myfunctions.js
  </code></pre>
  
  <p>When referencing with absolute path in my jsp , it is also working, but this is not best practice:</p>
  
  <pre><code>&lt;script type="text/javascript" src="http://localhost:8080/mycontextroot/js/myfunctions.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Any help ? I also would like to prevent using reference location path with ../../../</p>