title: How to define src attribute from web application context in JSP
body: <p>I wanted to use absolute path in src attribute, while including Javascript and CSS files in JSP. </p>
  
  <p>Using relative URLs would not serve my purpose, similar to the one below :</p>
  
  <pre><code>&lt;script type="text/javascript" src="../js/jquery-1.6.4.min.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>If I use absolute URL like,</p>
  
  <pre><code>&lt;script type="text/javascript" src="/appName/js/jquery-1.6.4.min.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Then I am hard-coding web application name which is not suitable again...</p>
  
  <p>The best option I found is :</p>
  
  <pre><code>&lt;base href="${pageContext.request.contextPath}"  /&gt;
  </code></pre>
  
  <p>But, it only works on href attributes like <code>&lt;a href="home.jsp" /&gt;</code></p>