<% @ Page contenttype = "text/html; charset = gb2312" buffer = "NONE" %> <br/> <% @ page import = "Java. util. * "%> <br/> <% <br/> // initialize the global variable <br/> int totalnum = 6; // total number of records <br/> int numperpage = 2; // number of records displayed per page <br/> int maxpagenum = 0; // maximum number of pages for this search <br/> int curpage = 1; // current page <br/> int startlocation = 0; // start position </P> <p> // vector searchresult = (vector) session. getattribute ("searchresult"); <br/> vector searchresult = New vector (); <br/> searchresult. add (0, String. valueof (0); <br/> searchresult. add (1, String. valueof (1); <br/> searchresult. add (2, String. valueof (2); <br/> searchresult. add (3, String. valueof (3); <br/> searchresult. add (4, String. valueof (4); <br/> searchresult. add (5, String. valueof (5); <br/> // numperpage = (integer) session. getattribute ("setpagenum ")). intvalue (); <br/> // totalnum = searchresult. s Ize (); <br/> maxpagenum = (totalnum % numperpage) = 0 )? Totalnum/numperpage :( totalnum/numperpage + 1); <br/> curpage = startlocation/numperpage + 1; </P> <p >%> <br/> <HTML> <br/> <pead> <br/> <meta http-equiv = Content-Type content = "Text /html; charset = gb2312 "> <br/> <title> query result page </title> <br/> <style> <br/> body {margin: 6px 0px; color: #000; Background-color: # FFF; font-family: Arial} <br/> table {border-Right: 0px; border-top: 0px; border-left: 0px; bord ER-BOTTOM: 0px} <br/> TD {font-size: 11pt; line-Height: 18px; font-family: Arial; text-align: Center} <br/>. P {padding-left: 18px; font-size: 14px; Word-Spacing: 4px} <br/># ft {clear: Both; Background: # e6e6e6; line-height: 20px; text-align: center; font-size: 12px; color: # 77C; font-family: arial} <br/> </style> <br/> </pead> <br/> <% </P> <p> If (request. getparameter ("startlocation ")! = NULL) <br/>{< br/> startlocation = integer. parseint (request. getparameter ("startlocation"); // obtain the current page number <br/> system. out. println ("startlocation =" + startlocation); <br/> curpage = (startlocation % numperpage) = 0 )? (Startlocation/numperpage) :( startlocation/numperpage + 1); <br/> curpage = curpage + 1; <br/> system. out. println ("curpage =" + curpage ); <br/>}</P> <p >%> <br/> <body> <br/> <form method = "Post"> <br/> <Table border = "0.5" width = "100%"> <br/> <tr bgcolor = "# 72963d"> <br/> <TD align = "center" class = "colstitle" nowrap height = "19"> <br/> query result <br/> </TD> <br/> </tr> <br/> <% <br/> If (curpage <maxpagenum) {<br/> sys TEM. out. println ("startlocation =" + startlocation); <br/> for (INT I = startlocation; I <startlocation + numperpage; I ++) {<br/> string result = (string) searchresult. elementat (I); <br/> out. println ("<tr bgcolor =/" # f1f0ed/">"); <br/> out. println ("<TD align =/" center/"nowrap Height =/" 19/">"); <br/> out. println (result); <br/> out. println ("</TD>"); <br/> out. println ("</tr>"); <br/>}< br/>} else {<br/> System. Out. println ("totalnum =" + totalnum); <br/> for (INT I = startlocation; I <totalnum; I ++) {<br/> string result = (string) searchresult. elementat (I); <br/> out. println ("<tr bgcolor =/" # f1f0ed/">"); <br/> out. println ("<TD align =/" center/"nowrap Height =/" 19/">"); <br/> out. println (result); <br/> out. println ("</TD>"); <br/> out. println ("</tr>"); <br/>}< br/> // searchresult. clear (); <br/>%> <br/> <Tr> <TD> <br/> <HR Align = "center" color = "#990066" width = "500"> <br/> </TD> <br/> <tr> <br/> <TD> <br/> <% <br/> If (curpage> 1) {<br/> out. println ("<a href =" myjsp. JSP? Startlocation = "+ (startlocation-numperpage); <br/> out. println (" "mce_href =" myjsp. jsp? Startlocation = "+ (startlocation-numperpage); <br/> out. println (""> previous page </a> "); <br/>}< br/> If (maxpagenum> 10) {<br/> int totalnumshow = curpage + 9; <br/> int startlocationpage = 0; <br/> If (totalnumshow> maxpagenum) {<br/> totalnumshow = maxpagenum; <br/>}< br/> If (maxpagenum> 11 & curpage> 11) {<br/> startlocationpage = curpage-11; <br/>}< br/> for (INT I = startlocationpage; I <totalnum Show; I ++) {<br/> if (I + 1 = curpage) {<br/> %> [<% = I + 1%>] <% <br/>} else {<br/> %> <a href = "myjsp. JSP? Startlocation = <% = I * numperpage %> "> <% = I + 1%> </a> <% <br/>}< br/>} <br/> else {<br/> for (INT I = 0; I <maxpagenum; I ++) {<br/> if (I + 1 = curpage) {<br/> %> [<% = I + 1%>] <% <br/>} else {<br/> %> <a href = "myjsp. JSP? Startlocation = <% = I * numperpage %> "> <% = I + 1%> </a> <% <br/>}< br/>} <br/> If (curpage <maxpagenum) {<br/> out. println ("<a href =" myjsp. JSP? Startlocation = "+ (startlocation + numperpage); <br/> out. println (" "mce_href =" myjsp. jsp? Startlocation = "+ (startlocation + numperpage); <br/> out. println (""> next page </a> "); <br/>}< br/>%> <br/> </TD> <br/> </tr> </P> <p> </table> <br /> </form> <br/> </body> <br/> </ptml>