title: finding the matched url-pattern used in a multiple servlet-mapping scenario
body: <p>Suppose I have a Java servlet that I want to use for two (or more) different url-patterns:</p>
  
  <pre><code>  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;MyServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/this/exact/path&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;MyServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/that/prefix/path/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;MyServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/yet/another/exact/path&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>MyServlet will be called for any of:</p>
  
  <pre><code>/this/exact/path
  /yet/another/exact/path
  /that/prefix/path/param1
  /that/prefix/path/param2.html
  </code></pre>
  
  <p>what I want to know is how can I tell from inside my code what was the path for which the request was matched for . (i.e. if the request was made to <code>/myapp/yet/another/exact/path</code> i want to get the string <code>/yet/another/exact/path</code>).</p>
  
  <p>I guess also that there should be a way to differentiate between the /that/prefix/path/ and what ever was matched with the * It would be nice if someone could tell me how this should be done.</p>
  
  <p>I tried <code>String path = req.getRequestURI()</code> but it also returns the /myapp part.</p>