I am using bootstrap framework for my JSP page. In a particular JSP page, i have put a big circle in the center of my page and other 6 smaller circles around the big one. To achieve this i have divided the the page to rows and spans. A minified version looks looks like this:
<div class=row>
<div class=span2> //Small circle 4 </div>
<div class=span2> //Small circle 6 </div>
</div>
<div class=row>
<div class=span2> //Small circle 1 </div>
<div class=span2> //Small circle 5 </div>
</div>
<div class=row>
//Big Circle
</div>
<div class=row>
<div class=span2> //Small circle 2 </div>
<div class=span2> //Small circle 3 </div>
</div>
The servlet sends to the JSP page how many circles to show (every time the total number of the small circles (=sum) is different. The sum is ε [0 , 6] ). What i have done so far is to put if statements to every span like this:
<% int i=0 %>
<div class=row>
<% if (i<sum) {%>
<div class=span2> //Small circle 4 </div> <% i++ } %>
<% if (i<sum) %>
<div class=span2> //Small circle 6 </div> <% i++ } %>
</div>
//etc...
With this approach, i add rows starting from the top to bottom so i put 4 small circles above the big one, and 2 small ones below the big circle. So:
- if sum = 3 i will have 3 small circles above and 0 below
- if sum = 5 i will have 4 small circles above and 1 below etc..
However if want to put the small circles as i have named them e.g.
- if sum = 3 show 1 small circle above and 2 below
I thought to nest all this to a while statement and say:
<% int i=0;
while (i < sum) { %>
<div class=row>
<% if (i == 4) { %>
<div class=span2> //Small circle 4 </div> <% } %>
<% if (i == 6) { %>
<div class=span2> //Small circle 6 </div> <% } %>
</div>
//etc..
<% i++; } %> //end of while
So theoretically i add rows gradually above and below of the Big circle. However, what is really happening is that in every loop the cirlces are added after the previous one. So they appear with this order: Big Circle and below of it, small cicle 1,2,3,4,5,6.
In Conclusion: Is there a way, that i can add rows to my page in a way that i prefer?