title: Pagination with JSP servlet and Bootstrap
body: <p>I have the following coding of a data table in JSP. it gives results taken from a servlet and post in the table. I need a pagination for the results.</p>
  
  <pre><code>&lt;table class="table table-striped hero-spacer"&gt;
                  &lt;thead&gt;
                      &lt;tr&gt;
                          &lt;td&gt;&lt;b&gt;Index Number&lt;/b&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;b&gt;First Name&lt;/b&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;b&gt;Last Name&lt;/b&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;b&gt;Date of Birth&lt;/b&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;%
                      int count = 0;
                      String style = "";
                      if (request.getAttribute("piList") != null) {
                          ArrayList al = (ArrayList) request.getAttribute("piList");
                          System.out.println(al);
                          Iterator itr = al.iterator();
                          while (itr.hasNext()) {
  
                              if ((count % 2) == 0) {
                                  style = "info";
                              }
                              count++;
                              ArrayList pList = (ArrayList) itr.next();
                  %&gt;
  
                  &lt;tbody&gt;
                      &lt;tr class="&lt;%=style%&gt;"&gt;
                          &lt;td&gt;&lt;%=pList.get(0)%&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;%=pList.get(1)%&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;%=pList.get(2)%&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;%=pList.get(3)%&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/tbody&gt;
                  &lt;%
                      }
                      }
                      if (count == 0) {
                  %&gt;
                  &lt;tbody&gt;
                      &lt;tr class="warning"&gt;
                          &lt;td colspan="4 text-center"&gt;&lt;b&gt;No Record Found..&lt;/b&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/tbody&gt;
                  &lt;%
                      }
                  %&gt;
              &lt;/table&gt;
  </code></pre>