title: Apache tiles - css and javascript files not visible to child pages
body: <p>i'm working on a jsp application developed with Apache Tiles. In short i'm trying to minimize the number of files that get downloaded on navigating to a new page, i've moved all css and javascript to the root jsp (a template in tiles.xml) and i haven't changed any cache setting (it should cache resources by default if i remember correctly).<br>
  The problem is that now child pages doesn't render correctly, as if pages weren't able to find some files. if i put our application script file inside an intermediate template then everything works fine but it get downloaded on each page i navigate. <br>
  How could i solve this problem or find any helpfull hint ? till now web searching hasn't provided anything useful.<br></p>
  
  <p>the code below is the tiles templates configuration and how pages are structured; please note that inner html fragments are load via jquery load function :</p>
  
  <pre><code>&lt;definition name="root" template="/WEB-INF/jsp/tiles/layouts/root.jsp"&gt;&lt;/definition&gt;
  &lt;definition name="HomeDOM" template="/WEB-INF/jsp/tiles/layouts/HomeDom.jsp"&gt;
  &lt;put-attribute name="menu" value="/WEB-INF/jsp/home/menu.jsp"&gt;&lt;/put-attribute&gt;
  &lt;/definition&gt;
  &lt;definition name="partialDOM" template="/WEB-INF/jsp/tiles/layouts/partialDOM.jsp"&gt;
      &lt;put-attribute name="submenu" value="/WEB-INF/jsp/tiles/common/empty.jsp" /&gt;
      &lt;put-attribute name="stockHeader" value="/WEB-INF/jsp/tiles/common/empty.jsp" /&gt;
      &lt;put-attribute name="main" value="/WEB-INF/jsp/tiles/common/empty.jsp" /&gt;
      &lt;put-attribute name="footer" value="/WEB-INF/jsp/common/footer.jsp" /&gt;
      &lt;/definition&gt;
  
      &lt;definition name="home" extends="partialDOM"&gt;
      &lt;put-attribute name="submenu" value="/WEB-INF/jsp/search/submenu.jsp" /&gt;
      &lt;put-attribute name="main" value="/WEB-INF/jsp/home/Home.jsp" /&gt;
      &lt;/definition&gt;
  
      &lt;definition name="widgetop" template="/WEB-INF/jsp/tiles/layouts/widgetDOM.jsp"&gt;
      &lt;put-attribute name="widget" value="/WEB-INF/jsp/home/widget.jsp" /&gt;
      &lt;/definition&gt;
  
      &lt;definition name="SimpleSearch" extends="partialDOM"&gt;
      &lt;put-attribute name="submenu" value="/WEB-INF/jsp/search/submenu.jsp" /&gt;
      &lt;put-attribute name="main" value="/WEB-INF/jsp/search/SimpleSearch.jsp" /&gt;
      &lt;/definition&gt;
  
      &lt;definition name="detail" template="/WEB-INF/jsp/tiles/layouts/widgetDOM.jsp"&gt;  
      &lt;put-attribute name="widget" value="/WEB-INF/jsp/details/detail.jsp" /&gt;
      &lt;/definition&gt;
  </code></pre>
  
  <p>root.jsp</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  ... all css and js
  includes myapp.js 
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div class="modal-backdrop fade1 in" id="hide"&gt;&lt;/div&gt;   
      &lt;!-- "container" --&gt;
          &lt;div class="container"&gt;
              &lt;div id="HomeDOM" &gt;
                  &lt;!-- dinamically loaded by JQuery at document ready--&gt;
              &lt;/div&gt;
          &lt;/div&gt;  
      &lt;!-- End"container" --&gt;
  
  ...some scripts... 
  
  ...some divs for modal windows...
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>HomeDom.jsp :</p>
  
  <pre><code>    &lt;tiles:insertAttribute name="menu" /&gt;
      &lt;div id="blocco"&gt;
              &lt;div id="partialDOM"&gt;
              &lt;!-- dinamically loaded by JQuery at document ready--&gt; 
              &lt;/div&gt;
      &lt;/div&gt;
  ...some scripts... 
  </code></pre>
  
  <p>I have to put myapp.js file in the following page too (partialDom) :</p>
  
  <pre><code>&lt;script src="${root}/javascript/js/myapp.js"&gt;&lt;/script&gt;
  
  
  &lt;tiles:insertAttribute name="submenu" /&gt;
  &lt;tiles:insertAttribute name="Header" /&gt;
  &lt;tiles:insertAttribute name="main" /&gt;
  &lt;tiles:insertAttribute name="footer" /&gt;
  
  &lt;script type="text/javascript" charset="utf-8"&gt;
      $j(document).ready(function($j) and other stuff     
  &lt;/script&gt;
  </code></pre>
  
  <p>EDIT :
  i've tried the solution described in the following post, i still see some downloads , should i replace all the jQuery.load with an ajax call?
  <a href="https://stackoverflow.com/questions/1537032/how-do-i-stop-jquery-appending-a-unique-id-to-scripts-called-via-ajax">How do I stop jquery appending a unique id to scripts called via ajax?</a></p>