title: Why does Tomcat resolve context path differently for certain url-mappings?
body: <p>So, I'm trying to write a servlet which can handle a url mapping like:</p>
  
  <blockquote>
  <pre><code>domain/context/servlet/resource_id
  </code></pre>
  </blockquote>
  
  <p>Before, when I was specifying the url pattern, I was just doing:</p>
  
  <blockquote>
    <p>/myServlet</p>
  </blockquote>
  
  <p>But, for what I'm trying to accomplish, I'm doing...</p>
  
  <blockquote>
    <p>/myServlet/*</p>
  </blockquote>
  
  <p><strong>THE PROBLEM I'M RUNNING INTO</strong>:</p>
  
  <p>I've been using relative path (so, just the file location with respect to my WebContent folder) for my static files (css/js/etc) now that I'm using the <code>/myServlet/*</code> mapping, the requests for the all static files are now being handled by myServlet.  So, basically, the static resources are now resolving to:</p>
  
  <blockquote>
    <p>domain/context/myServlet/relative_path_I_provide</p>
  </blockquote>
  
  <p>as opposed to</p>
  
  <blockquote>
    <p>domain/context/relative_path_I_provide</p>
  </blockquote>
  
  <p>I'm sure I can fix this myself by just building the absolute path for the resource as opposed to relying on the relative path; but I'm just wondering, why is the resolved path for the static resource changing when I'm using <code>/myServlet/*</code> url pattern as opposed to <code>/myServlet</code> ?</p>
  
  <p>EDIT:</p>
  
  <p>My folder structure is like</p>
  
  <pre><code>WebContent
     |
     |
     |-- debug
           |
           |-- css
                |
                |-- file.css
  </code></pre>
  
  <p>and I'm adding them in a link tag like:</p>
  
  <pre><code>&lt;link href="debug/css/file.css" rel="stylesheet" type="text/css"&gt;
  </code></pre>