⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fy_jsp.java

📁 新闻发布系统
💻 JAVA
字号:
package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;

public final class fy_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.Vector _jspx_dependants;

  private org.apache.jasper.runtime.ResourceInjector _jspx_resourceInjector;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html; charset=GB2312");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;
      _jspx_resourceInjector = (org.apache.jasper.runtime.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector");

      out.write("\r\n");
      out.write("\r\n");

int dipage=1;//当前页码数默认为1
String pages=request.getParameter("dipage");
if(pages==null)
{
  pages="1";
}
try
{
  dipage=Integer.parseInt(pages);
}
catch(Exception e)
{
  dipage=1;
}

      out.write("\r\n");
      out.write("<HTML>\r\n");
      out.write("<title>分页程序</title>\r\n");
      out.write("<BODY>\r\n");
      out.write(" ");
 Connection con=null;
    Statement stm=null;
    ResultSet rs=null;
    String strparentid=request.getParameter("parenttitleId");
    if(strparentid!=null)
            {
            int parenttitleid=Integer.parseInt(strparentid);}
    try
    {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    }
    catch(ClassNotFoundException e)
    {
      out.print("类找不到!");
    }
    try
    {
       con=DriverManager.getConnection("jdbc:odbc:news");
         stm=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
   String sql="select * from SecondLevelTitle where parenttitleid=8";
  // String   sql="delete * from SecondLevelTitle where   id='"+parenttitleid+"'";
         rs=stm.executeQuery(sql);
         int countRecord=0;//记录条数
         int countPageRecord=0;//每页记录条数
         int countPage=0;//总页数
         countPageRecord=5;//每页5条记录,要设置每页记录条数就更改这个变量的值
         //得到记录的条数
         rs.last();
         countRecord=rs.getRow();
         //得到总页数
         if(countRecord%countPageRecord==0)
            countPage=countRecord/countPageRecord;
         else
            countPage=countRecord/countPageRecord+1;
         //把记录指针移至当前页第一条记录之前
         if((dipage-1)*countPageRecord==0)
            rs.beforeFirst();
         else
            rs.absolute((dipage-1)*countPageRecord);
         out.print("<Table Border style='font-size: 10pt' bordercolor='silver' align='center'>");
           out.print("<TR>");
            out.print("<Td width=100>"+"序号");
            out.print("<Td width=100>"+"二级标题名称");
            out.print("</TR>");
       int i=0;
     while(rs.next())
       { 
           out.print("<TR>");
             out.print("<TD >"+rs.getString("id")+"</TD>");
             out.print("<TD >"+rs.getString("titleName")+"</TD>");
            
        out.print("</TR>") ;
        i++;
        if(i>=countPageRecord) break; //当前页显示完,则退出循环
        }
        out.print("<TR><td colspan=8 align=center>");
           out.print("共"+countRecord+"条记录,共"+countPage+"页,当前第"+dipage+"页,每页"+countPageRecord+"条记录,");
           if(dipage==1)//当前是首页
              ;
           else//当前不是首页
           {
              out.print("<a href=fy.jsp?dipage=1>首页</a>,");
              out.print("<a href=fy.jsp?dipage="+(dipage-1)+">上一页</a>,");
           }
           if(dipage==countPage)//当前是末页
              ;
           else//当前不是末页
           {
              out.print("<a href=fy.jsp?dipage="+(dipage+1)+">下一页</a>,");
              out.print("<a href=fy.jsp?dipage="+countPage+">末页</a>");
           }        
         
           out.print("</td></tr>");
        out.print("</Table>");
        con.close();
     }
   catch(SQLException e1)
   {
     out.println("发生错误!错误原因:"+e1.getMessage());

   }
 
      out.write("\r\n");
      out.write("</BODY>\r\n");
      out.write("</HTML> ");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -