JSP Paging program code
<%
String s;
String theURL;
Theurl= "products.jsp";
S=request.getparameter ("s");
if (s!=null) {
S=new String (Request.getparameter ("s"). GetBytes ("iso-8859-1"));
Theurl= "products.jsp?s=" +s;
}
Statement stmt=conn.createstatement (resultset.type_scroll_sensitive,resultset.concur_read_only);
ResultSet rs=stmt.executequery ("select * from Hl_smallclass WHERE modiname= ' products '");
while (Rs.next ()) {
String smallname = rs.getstring ("Smallname");
%>
<tr>
<TD height= "align=" center "style=" Background:url (images/ntb_bg.jpg) no-repeat Center "><a href=" Products.jsp?modi= Products &b=<%=rs.getstring ("Bigname")%>&s=<%=smallname%> ' >::<%=smallname %>::</a></td>
</tr>
<%
}
Rs.close ();
%>
</table>
</td>
<TD width= "687" rowspan= "2" align= "center" valign= "Top" bgcolor= "#FFFFFF" style= "background: #fff URL (images/main_ bg.jpg) repeat-x top; " ><table style= "margin-top:5px" width= "98%" border= "0" cellspacing= "0" cellpadding= "0" >
<tr>
<TD width= "4%" height= "align=" center "style=" Border-bottom: #ebebeb 1px solid "></td>
<TD width= "96%" align= "left" style= "Border-bottom: #ebebeb 1px solid" ><a href= "index.jsp" > Home </a> > <a href= "products.jsp" > Product show </a> > <% if (s!=null) {out.print (s);}%></td>
</tr>
<tr>
<TD colspan= "2" align= "center" ><table width= "+" border= "0" cellpadding= "0" cellspacing= "0" style= " Border-bottom: #E7E7E7 1px solid;margin-top:15px; " >
<tr>
<TD height= align= "center" > Below is our company <% if (s!=null) {out.print (s);} if (S==null) {%> all <%}%> products; click the corresponding Picture or text Enter view detailed product information </td>
</tr>
</table>
<table style= "margin-top:5px" width= "100%" border= "0" cellspacing= "0" cellpadding= "0" >
<tr>
<TD align= "center" valign= "Top" >
<table style= "margin-top:8px" width= "96%" border= "0" cellspacing= "0" cellpadding= "0" >
<tr>
<%
int pagesize=9;
int showpage=1;
int reccount=0;
int t=0;
int pagecount=0;
String topage = request.getparameter ("page");
String SQLP;
Sqlp= "SELECT * from Hl_product ORDER by ID Desc";
if (s!=null) {
Sqlp= "SELECT * from hl_product WHERE smallname= '" +s+ "";
}
ResultSet rsa=stmt.executequery (SQLP);
if (Rsa.next ()) {
Rsa.last ();
Reccount=rsa.getrow ();
Pagecount= (reccount%pagesize) ==0? ( reccount/pagesize):(reccount/pagesize) +1);
if (topage!=null)
Showpage=integer.parseint (ToPage);
Rsa.absolute ((showPage-1) *pagesize+1);
for (int i=1;i<=pagesize;i++) {
String TTT = rsa.getstring ("title");
Ttt=ttt.substring (0,10);
int Id=rsa.getint ("ID");
%>
<TD align= "Left" >
<table style= "margin-top:15px width=" 143 "height=" "border=" 0 "cellpadding=" 0 "cellspacing=" 0 "bgcolor=" # F5f5f5 ">
<tr>
<TD height= "align=" "Center" ><table width= "138" border= "0" cellpadding= "0" cellspacing= "0" class= "k_a_1" >
<tr>
<TD height= "align=" "Center" bgcolor= "#FFFFFF" ><a target= "_blank" href= "proshow.jsp?id=<%=id%>" ></a></td>
</tr>
</table></td>
</tr>
<tr>
<TD height= "align=" "Center" class= "F-12-black" ><a target= "_blank" href= "proshow.jsp?id=<%=id%>" ><%=rsa.getstring ("title")%></a></td>
</tr>
</table>
</td>
<%
t++;
if (i%3==0) out.print ("</tr><tr>");
if (! Rsa.next ())
Break
}
}
Rsa.close ();
%>
<tr>
</table>
<table align= "center" >
<form
action= "News.asp?classid=&bigclassname= News Online"
Method= "POST" name= "Showpages" id= "Showpages" >
<tbody>
<tr>
<td><% if (showpage>1) {%><a class= ' f-12-black ' href= ' <%=theurl%>& Page=1 ' > Home </a> <%} if (showpage>1) {%><a class= ' f-12-black ' href= ' "<%=theurl%>&page=" <%= showPage-1%> ' > Prev </a> <%} if (showpage<pagecount) {%> <a class= ' F-12-black ' href= ' <%=theurl%>&page=<%= showpage+1%> ' > Next </a> <%}%>& nbsp;<% if (showpage<pagecount) {%><a class= ' f-12-black ' href= ' <%=theurl%>&page=<%= ' PageCount%> ' > Last </a> <% }%> page: <%=showpage%>/<% =pagecount%> page Total <%=recCount%> records <a class= ' F-12-black ' > go to <select name= ' sel_page ' onchange= ' Javascript:location=this.options[this.selectedindex].value; ' ><% for (int I=1;i<=pagecount;i++) { %> <option value= ' <%=theurl%>&page=<%=i%> ' <% if (i==showPage) {%> Selected <%}%>><%=i%></option><%}%></select> page </a></td>
</tr>
</tbody>
</form>
<tr>
<td></TBODY></td>
</tr>
</table>
<BR/></td>
</tr>
</table></td>
</tr>
</table></td>
<TD width= "rowspan=" 3 "style=" Background:url (images/rightbg.jpg) repeat-y left "> </td>
</tr>
</table>
<%
Stmt.close ();
%>