title: How is using "<%=request.getContextPath()%>" better than "../"
body: <p>I have worked on number of J2EE projects where the view layer is JSP. In most projects, I have seen that we reference external resources i.e. images, javascript, jsp's, css etc. using the contextPath in the scriptlet.</p>
  
  <p>The code is as follows,</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;title&gt;GC Demo Using HandlebarsJS&lt;/title&gt;
      &lt;script type="text/javascript" src="&lt;%=request.getContextPath()%&gt;/js/jqueryUI-AutoComplete/jquery-1.9.1.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="&lt;%=request.getContextPath()%&gt;/js/jqueryUI-AutoComplete/jquery-ui-1.10.3.custom.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="&lt;%=request.getContextPath()%&gt;/js/handlebarsJS/handlebars.js"&gt;&lt;/script&gt;
      &lt;link rel="stylesheet" type="text/css" href="${pageContext.servletContext.contextPath}/js/jqueryUI-AutoComplete/jquery-ui-1.10.3.custom.css"&gt;
  </code></pre>
  
  <p>From the above jsp, here I am importing the external resources which are in my same project bundle i.e. in my war.</p>
  
  <p>Now the same above JSP can be written as below code,</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;title&gt;GC Demo Using HandlebarsJS&lt;/title&gt;
      &lt;script type="text/javascript" src="../js/jqueryUI-AutoComplete/jquery-1.9.1.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="../js/jqueryUI-AutoComplete/jquery-ui-1.10.3.custom.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="../js/handlebarsJS/handlebars.js"&gt;&lt;/script&gt;
      &lt;link rel="stylesheet" type="text/css" href="../js/jqueryUI-AutoComplete/jquery-ui-1.10.3.custom.css"&gt;
  </code></pre>
  
  <p>Here in the second example too I am referencing the resources present in my war.</p>
  
  <p>Now considering both of the above two cases, the first case is given more significance as a best practise.</p>
  
  <p>Why?</p>
  
  <p>and what are the drawbacks of using the second case?</p>
  
  <p>Does using the second case, our project gets more tightly coupled with the contextpath?</p>
  
  <p>Please explain to me.</p>