how to count number of records found from database and display in jsp page using struts2?
<pre><code>        List&lt;CommonDTO&gt; subjectList = new ArrayList&lt;CommonDTO&gt;();
            try {

                pstmt = conn.prepareStatement(SLCMQueryConstant.SEARCH_SUBJECT);
                pstmt.setString(1, commonDTO.getSubjectName());
                pstmt.setString(2, commonDTO.getSubjectCode());

                if(commonDTO.getIsActive()==0){

                    pstmt.setInt(3, commonDTO.IsActive = 1 );

                }
                else{

                    pstmt.setInt(3, commonDTO.IsActive= 0);
                }

                rs = pstmt.executeQuery();
                int count = 0;
                while (rs.next()) {
                    count++;
                    CommonDTO commondto = new CommonDTO();
                    commondto.setSubjectId(rs.getInt("Subject_Id"));
                    commondto.setSubjectCode(rs.getString("Subject_Code"));
                    commondto.setSubjectName(rs.getString("SubjectName"));
                    commondto.setSubjectNameHindi(rs.getString("SubjectName_Hindi"));
                    commondto.setIsActive(rs.getInt("Is_Active"));
                    commondto.setViewcount(count);
                    subjectList.add(commondto);
                }
                System.out.println(count);
            }
        return subjectList;

    public static final String SEARCH_SUBJECT = new StringBuilder("").
    append(" SELECT Subject_Id,Subject_Code,SubjectName,SubjectName_Hindi,Is_Active").
        append(" FROM  M_Subject_Master WHERE   Subject_Id=IFNULL(NULL,Subject_Id) ").
        append(" AND (SubjectName IS NULL OR SubjectName LIKE CONCAT('%',?,'%'))"). 
        append(" AND (Subject_Code IS NULL OR Subject_Code LIKE CONCAT('%',?,'%'))").
        append(" AND Is_Active = ?  ").
        append(" ORDER BY SubjectName").toString();
</code></pre>

<p>JSP Page to show number of records found
 =========================================</p>

<pre><code>&lt;s:iterator value="subjectList" var="quesvar" status="questat"&gt;
                    &lt;s:hidden value="%{subjectId}" name="commonDTO.subjectId" id="subjectId"&gt;&lt;/s:hidden&gt;
                    &lt;td valign="top" class="style11" style="width: 20%;text-align:left"&gt;No.Of Records Found&lt;s:property  value="subjectList[#questat.index].viewcount"/&gt;&lt;/td&gt;
                        &lt;tr class="item"&gt;
                        &lt;td valign="top" class="style10" style="width: 10%;text-align:left"&gt;&lt;s:property value="#questat.count"/&gt;&lt;/td&gt;
                            &lt;td valign="top" class="style11" style="width: 20%;text-align:left"&gt;&lt;s:property  value="subjectList[#questat.index].subjectCode"/&gt;&lt;/td&gt;
                            &lt;td valign="top" class="style11" style="width: 20%;text-align:left"&gt;&lt;s:property  value="subjectList[#questat.index].subjectName"/&gt; &lt;/td&gt;


                            &lt;td valign="top" class="style11" style="width: 20%;"&gt;&lt;a href="#" onClick="editSubject(&lt;s:property  value="subjectList[#questat.index].subjectId"/&gt;)" &gt;View/Edit&lt;/a&gt;

                        &lt;/tr&gt;
                    &lt;/s:iterator&gt;
</code></pre>

<p>How can I count number of records from database and print on jsp page ?
I don't use another prepare statement for count how can i display number of records fetch in jsp from database.</p>