title: CQ5: How to programmatically find out the Resource given a URL?
body: <p>According to ResourceResolver Interface:</p>
  
  <p><a href="http://dev.day.com/docs/en/cq/current/javadoc/org/apache/sling/api/resource/ResourceResolver.html" rel="nofollow">http://dev.day.com/docs/en/cq/current/javadoc/org/apache/sling/api/resource/ResourceResolver.html</a></p>
  
  <p>There are three ways to resolve either path or request to a Resource:</p>
  
  <ol>
  <li><p><code>Resource resolve(HttpServletRequest request)</code>
   Deprecated. as of 2.0.4, use resolve(HttpServletRequest, String) instead.</p></li>
  <li><p><code>Resource resolve(HttpServletRequest request, String absPath)</code> 
   Resolves the resource from the given absPath optionally taking
   HttpServletRequest into account, such as the value of the Host request header.</p></li>
  <li><p><code>Resource resolve(String absPath)</code>
   Resolves the resource from the given absolute path.</p></li>
  </ol>
  
  <p>But if I have a random given URL string (e.g. <code>http://www.mycompany.com/whatever.html</code>), how do I programmatically find out the corresponding Resource of the given URL? </p>