title: How can I set the javascript path in my JSP
body: <p>I am working on SpringMVC3.2, JSP and Tomcat using Maven build. My web application structure is shown like below.</p>
  
  <pre><code>tomcat
    |-- webapps
      |-- MyApp
        |-- css
        |-- js
          |-- jquery.js
        |-- images
        |-- META-INF
        |-- WEB-INF
          |-- classes
          |-- lib
          |-- src
          |-- web.xml
          |-- pages
               |-- index.jsp
  </code></pre>
  
  <p>I set the JavaScript path in the index.jsp like following:</p>
  
  <pre><code>&lt;script src="../js/jquery.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>But it could not load the Javascript file. I changed path and moved the file here and there but everything did not work. What am I missing? Please help me.</p>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT
  Actually, I found the answer through different community.</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8" %&gt;
  &lt;%@page isELIgnored="false" %&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;
  &lt;c:set var="contextPath" value="${pageContext.request.contextPath}"/&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;link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" /&gt;
      &lt;script src="${contextPath}/js/jquery-1.9.1.js"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is not a beautiful way but it works fine for me and if you want different solution then see my answer below.</p>