title: Struts 2 conditional div tag
body: <p>I am working on my website and trying to print out portfolio objects from the database. The page where I print them out to has pagination.</p>
  
  <p>I use a script to create a new page when the following tag is used:</p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>&lt;div class="pics"&gt;
  ...
  &lt;/div&gt;
  </code></pre>
  
  <p>A maximum of 8 anchor tags only should go inside the above div. The anchor tags aren't anything special, they do use <code>&lt;s:property&gt;</code> tags but that's about it.</p>
  
  <p>In order to achieve this functionality, I've tried the following:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;c:set var="counter" value="0"/&gt;
  &lt;s:iterator value="allPortfolio"&gt;
      &lt;c:if test="${(counter mod 8) == 0}"&gt;
          &lt;div class="pics"&gt;
     &lt;/c:if&gt;
  
     &lt;a href="&lt;s:property value="filename"&gt;"&gt;Download&lt;/a&gt;
  
      &lt;c:if test="${(counter mod 8) == 0}"&gt;
          &lt;/div&gt;
      &lt;/c:if&gt;
  
      &lt;c:set var="counter" value="${counter+1}"/&gt;
  
  &lt;/s:iterator&gt;
  </code></pre>
  
  <p>This code, however, creates 11 pages (1 per portfolio object in my database). Where it should create just 2 pages with 8 items on the first and the remaining 3 on the second.</p>
  
  <p>In other words, there should be just 2 of</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div class="pics"&gt;
  ...
  &lt;/div&gt;
  </code></pre>
  
  <p>One with 8 anchor tags in and one with 3 anchor tags in.</p>
  
  <p>Instead, this is the code that gets created once the page loads:</p>
  
  <pre class="lang-html prettyprint-override"><code> &lt;div class="pics"&gt;
       &lt;a href="1ba918625bca57f6e059c2d05393010b04da5ed6.png"&gt;Download&lt;/a&gt;
   &lt;/div&gt;
   &lt;a href="ec49d4ca243a481b7fa819dfea783e0dd8f5a431.jpg"&gt;Download&lt;/a&gt;   
   &lt;a href="1b4ab5a3bebdf88045ef3818e852185c86e33048.png"&gt;Download&lt;/a&gt;
   &lt;a href="e12eaed32a97bb78ddd863696ca510d943c4d978.png"&gt;Download&lt;/a&gt;
   &lt;a href="2b6ee029b3fcef21b0a220a6b14de16206ce588b.png"&gt;Download&lt;/a&gt;
   &lt;a href="e3e94e7ac6bfb09ca012d30912525848f2d361ed.png"&gt;Download&lt;/a&gt;
   &lt;a href="f07e24b31fb65e38aa3d4bbe97a24a71c281aae7.png"&gt;Download&lt;/a&gt;
   &lt;a href="dd41b536ca45642fa9827311498b9480d6df9be8.png"&gt;Download&lt;/a&gt;
   &lt;div class="pics"&gt;
       &lt;a href="a2ad0d4b73daa3311e9f9b16dcd7d9476cd6e748.png"&gt;Download&lt;/a&gt;
   &lt;/div&gt;
   &lt;a href="45fa47125a5dfe3608d6d80fb0a9ba1f5c444264.png"&gt;Download&lt;/a&gt;
   &lt;a href="ee9b1571aa22e935772792ac363cc95e2a77bdfd.png"&gt;Download&lt;/a&gt;
  </code></pre>