title: How to pass values from JSP to tiles attribute?
body: <p>I am converting an existing Tiles 1 webapp to Tiles 2 architecture. I am having trouble passing values from JSP page to tiles attributes.</p>
  
  <p>Here is my tiles definition file (tiles-definition.xml)</p>
  
  <pre><code>&lt;tiles-definitions&gt;
  
      &lt;definition name="cda.layout" template="/jsp/layouts/layout.jsp"&gt;
          &lt;put-attribute name="pageTitle" value="StoryTitle" type="string"/&gt;
          &lt;put-attribute name="pageHeader" value="StoryHeader" type="string"/&gt;
          &lt;put-attribute name="resources" value="" type="string"/&gt;
      &lt;/definition&gt;
  
  &lt;/tiles-definitions&gt;
  </code></pre>
  
  <p>The layout.jsp looks like:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
      &lt;title&gt;&lt;tiles:insertAttribute name="pageTitle" flush="true"/&gt;&lt;/title&gt; 
      &lt;/head&gt;
  
      &lt;body&gt;
      ...
      ...
  
      &lt;div class="content"&gt;
      &lt;h1&gt;&lt;tiles:insertAttribute name="pageHeader" flush="true"/&gt;&lt;/h1&gt;
      &lt;/div&gt;
  
      ...
      ...
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I have a story page which uses the layout and need to pass values to template attributes.</p>
  
  <pre><code>    &lt;%
      // create a business object and populate
      String mytitle= story.getTitle();
      String myheader = story.getHeader();
      %&gt;
  
  &lt;tiles:insertTemplate template="../layouts/layout.jsp"  flush="false" &gt;
      &lt;tiles:putAttribute name="pageTitle" value="${mytitle}"/&gt;
      &lt;tiles:putAttribute name="pageHeader"value="${myheader}"/&gt;
  &lt;/tiles:insertTemplate&gt;
  </code></pre>
  
  <p>In the story.jsp, I can System.out.print() the values for mytitle, myheader and they are showing correct. But, these values are NOT passed on to the tile attributes.</p>
  
  <p>Any idea how to fix this?</p>