title: I don´t catch my javascript file with spring mvc
body: <p>I have an app web developed with spring 2.5.6. But I have a problem with javascript file because my app don´t catch those files. I don´t work with them and for more I make, I don´t find a solution.</p>
  
  <p>This is my structure</p>
  
  <pre><code>src
     java
        controller
     test
     resource
     static
        js
          files.js
     WEB_INF
        pages
        spring
        lib 
        web.xml
  </code></pre>
  
  <p>Those are my files
  web.xml</p>
  
  <pre><code>&lt;web-app 
      xmlns="http://java.sun.com/xml/ns/javaee" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
            http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      version="2.5"&gt;
  
    &lt;display-name&gt;Web Logistic&lt;/display-name&gt;
  
    &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;
              /WEB-INF/spring/root-context.xml,
              /WEB-INF/spring/spring-beans.xml
          &lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;mvc-dispatcher-servlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
           &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/spring/root-context.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;mvc-dispatcher-servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;log4jConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;classpath:/log4j.properties&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.util.Log4jConfigListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;!-- Spring Security --&gt;
      &lt;filter&gt;
          &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
          &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
      &lt;/filter&gt;
  
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>root-context.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="
            http://www.springframework.org/schema/beans      
            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
            http://www.springframework.org/schema/context  
            http://www.springframework.org/schema/context/spring-context-2.5.xsd"&gt; 
  
  ...
  
  &lt;!--     Configuramos Spring MVC --&gt;
      &lt;import resource="mvc-dispatcher-servlet.xml"/&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>mvc-dispatcher-servlet.xml</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:p="http://www.springframework.org/schema/p"
      xsi:schemaLocation="
            http://www.springframework.org/schema/beans      
            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
            http://www.springframework.org/schema/context   
            http://www.springframework.org/schema/context/spring-context-2.5.xsd"&gt;  
  
  ...
  
      &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver" &gt;
          &lt;property name="viewClass"&gt;
              &lt;value&gt; org.springframework.web.servlet.view.tiles2.TilesView&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
      &lt;bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"&gt;
          &lt;property name="definitions"&gt;
              &lt;list&gt;
                  &lt;value&gt;/WEB-INF/layouts/layouts.xml&lt;/value&gt; 
              &lt;/list&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;!-- View Resolvers --&gt;
  &lt;!--    Resuelve la ubicion de las vistas .jsp de @Controllers en la ruta /WEB-INF/pages --&gt;
      &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="prefix" value="/WEB-INF/pages/"/&gt;
          &lt;property name="suffix" value=".jsp"/&gt;
      &lt;/bean&gt;
  
      ...
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>index.jsp (with call to javascript file)</p>
  
  <pre><code>&lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%&gt;
  &lt;%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%&gt;    
  &lt;html&gt;
  &lt;head&gt;
      &lt;script type="text/javascript" src="../static/js/md5.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
  
          function passwordToMD5()
                  {
                      alert("estamos en el metodo de MD5");
                      var aleat = document.forms[0].aleat;
                      var jqPassClear = document.forms[0].password;
                      alert(aleat.value);
                      alert(jqPassClear.value);
                      //document.forms[0].user.value = $.trim(document.forms[0].user.value);
  
                      if(jqPassClear.value != "")
                      {
                          alert("entramos en el método jqPassClear");
                          alert($.trim(jqPassClear.value)));
                          document.forms[0].password.value = hex_md5(hex_md5($.trim(jqPassClear.value)));
                          //document.forms[0].password.value = hex_md5(aleat.value);
                          //document.forms[0].password.value = hex_md5(aleat.value);
                          alert(document.forms[0].password.value);
                      }
                      else
                      {
                          document.forms[0].password.value = "";
                      }
  
                      //document.forms[0].passwordClear.value = document.forms[0].user.value;
                  }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form:form modelAttribute="login" action="" method="post"&gt;
          &lt;form:errors path="*" cssClass="errorblock" element="div" /&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;spring:message code="message.user.userName" text="default text" /&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;form:input path="name" /&gt;
                  &lt;/td&gt;
                  &lt;td&gt;&lt;form:errors path="name" cssClass="error" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;spring:message code="message.user.password" text="default text" /&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;form:password path="password" /&gt;
                  &lt;/td&gt;
                  &lt;td&gt;&lt;form:errors path="password" cssClass="error" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              ...
              &lt;tr&gt;
                  &lt;td colspan="3"&gt;&lt;input type="submit" onclick="passwordToMD5();" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;        
      &lt;/form:form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is my filter</p>
  
  <pre><code>public class ProvisionResourceDispatcherServlet extends HttpServlet
  {
      /**
       * 
       */
      private static final long serialVersionUID = -7319714368828547681L;
  
      @Override
      public void init () throws ServletException
      {
      }
  
      @Override
      public void doGet (HttpServletRequest req, HttpServletResponse rsp) throws ServletException, IOException
      {
          String servletPath = req.getServletPath (); // /resource
  
          String url = servletPath;
          String lastPath = StringUtils.substringAfterLast (servletPath, "/");
          String extension = StringUtils.substringAfterLast (lastPath, ".");
  
          try
          {
              RequestDispatcher dispatcher = null;
              if (!StringUtils.isEmpty (extension)
                      &amp;&amp; ("js".equals (extension) || "css".equals (extension) || "jpg".equals (extension))
                      || "bmp".equals (extension) || "gif".equals (extension))
              {
                  dispatcher = req.getRequestDispatcher (url);
              }
  
              if (dispatcher != null)
              {
                  dispatcher.include (req, rsp);
              }
              else
              {
                  rsp.sendError (404);
              }
          }
          catch (Exception e)
          {
  
              if (!rsp.isCommitted ())
              {
                  rsp.sendError (500);
              }
          }
      }
  }
  </code></pre>