title: Correct way for responding resources from http server
body: <p>I have this index.html page:</p>
  
  <pre><code>   &lt;html&gt;
      &lt;head&gt;
       &lt;title&gt;My Site&lt;/title&gt;
       &lt;link rel="stylesheet" type="text/css" href="css/example.css" /&gt;
      &lt;/head&gt;
      &lt;body&gt;
       &lt;h2&gt;Hello world&lt;/h2&gt;
       &lt;p&gt;Image:&lt;/p&gt;
       &lt;img src="someimage.jpg" alt="W3Schools.com" width="104" height="142"&gt;
      &lt;/body&gt;
     &lt;/html&gt;
  </code></pre>
  
  <p>And I wrote a simple java Http server. This server handles the request, load <code>index.html</code> from the resources folder and responses to the client(browser). The client sees <code>index.html</code> but without resources(images, CSS, js). Because browser after loading <code>index.html</code> tries to load all resources included to this page. But resources in the server. I Wrote a new handler with path like <code>/assets/</code> and tried to replace all links to resources in <code>index.html</code> like this:</p>
  
  <pre><code>&lt;img src="someimage.jpg" width="104" height="142"&gt;
  </code></pre>
  
  <p>to </p>
  
  <pre><code>&lt;img src="/assets/someimage.jpg" width="104" height="142"&gt;
  </code></pre>
  
  <p>After that in <code>/assets/</code> handler, I cut the first part of URI (<code>/assets/</code>) and try load from resources second part of URI(<code>someimage.jpg</code>);</p>
  
  <p>It works, but I can not load CSS. Because I replace <code>pageAsString.replace("src=\"", "/assets/");</code>
  but CSS in <code>href="css/example.css"</code></p>
  
  <p>Maybe I doing something wrong and this approach is bad? How can I return index.html to the client and give the ability for loading resources from the server?</p>