<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.util.*" %>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<jsp:useBean id="PageBean" scope="page" class="pagetest.PageCountTest" >
</jsp:useBean>

<%
int PageCount;
PageCount= PageBean.getPageCount(20); //以20条纪录为一页得到总页数

String Direction=new String();
Direction=(String)request.getParameter("Direction");
if(Direction==null) Direction=new String("3");

String curPage=(String)session.getAttribute("CCurPage");//得到当前页号
if(curPage==null) session.setAttribute("CCurPage",String.valueOf(1));
//如果当前页为空则置当前页号为1
int CurPage=Integer.parseInt((String)session.getAttribute("CCurPage"));

if(Direction.equals("1")) // Direction=="1"则向下翻页
{
    session.setAttribute("CCurPage",String.valueOf(CurPage+1));
	CurPage+=1;
}
else if(Direction.equals("0"))// Direction=="0"则向上翻页
{
    session.setAttribute("CCurPage",String.valueOf(CurPage-1)); 
	CurPage-=1;
}
	
Vector data;
data=PageBean.ReadInfByPage(CurPage,20);//得到当前页的数据
if(data==null) response.sendRedirect("error.htm");//数据为空转向错误页
%>
<table width="991" border="0">
   <tr> 
      <td width="8%">          
<% if(CurPage>1){%><!--当前页大于1则可向前翻页 -->
          <a href="file:///H|/tomcat/webapps/ROOT/PageCount/CourseResult.jsp?Direction=0">上一页</a> 
<% }else {%>上一页<%}%></td>
<td width="8%">
<%	if(CurPage<PageCount){%> <!--当前页小于总页数则可向后翻页 -->
    <a href="file:///H|/tomcat/webapps/ROOT/PageCount/CourseResult.jsp?Direction=1">下一页</a> 
<%} else {%> 下一页<%}%>  </td>    
      <td width="8%">第<%=CurPage%>页</td>  <!--输出当前页号-->
      <td width="9%">共<%=PageCount%>页</td> <!--输出总页数-->
  </tr>
 <%
   for(int i=0;i<data.size();i++)
   {
 %>
   <tr>
     <td><%=(String)data.elementAt(i)%> </td>
   </tr>     
 <%
   }
 %>  
</table>


<body>

</body>
</html>
