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

📄 handledisplay_jsp.java

📁 纯粹jsp的留言板,使用了mvc
💻 JAVA
字号:
package org.apache.jsp;

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

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

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

  private static java.util.List _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.AnnotationProcessor _jsp_annotationprocessor;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
  }

  public void _jspDestroy() {
  }

  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=UTF-8");
      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;

      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n");
      out.write("   \"http://www.w3.org/TR/html4/loose.dtd\">\n");
      out.write("\n");
      out.write("<html>\n");
      out.write("    <head>\n");
      out.write("        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n");
      out.write("        <title>handle display</title>\n");
      out.write("    </head>\n");
      out.write("    <body>\n");
      out.write("        ");
            try{                Class.forName("com.mysql.jdbc.Driver").newInstance();            }            catch(Exception e){            }            ResultSet rs=null;            Connection conn;            String url="jdbc:mysql://localhost/taotao";            String user="taotao";            String password=".nothing";            conn=DriverManager.getConnection(url,user,password);            Statement stmt;            String sql="select * from messages "+" Order By number Desc";            stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);            rs=stmt.executeQuery(sql);        
      out.write("\n");
      out.write("        ");
            int intPageSize;             int intRowCount;             int intPageCount;             int intPage;             String strPage;            int i;            intPageSize = 10;            strPage = request.getParameter("page");            if(strPage==null){                intPage = 1;            }            else            {                intPage = Integer.parseInt(strPage);                if(intPage<1){ intPage = 1;}            }            rs.last();             intRowCount = rs.getRow();             intPageCount =(intRowCount+intPageSize-1) / intPageSize;            if(intPage>intPageCount) intPage = intPageCount;            if(intPageCount>0){                rs.absolute((intPage-1) * intPageSize+1);                 i = 0;                 while(i< intPageSize && !rs.isAfterLast()){                    int num=rs.getInt("number");                    String name=rs.getString("id");                    name=name.replaceAll("<","&lt;");                    name=name.replaceAll(">","&gt;");                    String content=rs.getString("content");                    content=content.replaceAll("<","&lt;");                    content=content.replaceAll(">","&gt;");                    String recontent=rs.getString("recontent");                    if(recontent!=null){                        recontent=recontent.replaceAll("<","&lt;");                        recontent=recontent.replaceAll(">","&gt;");                    }            
      out.write("\n");
      out.write("            <table border=1 bgcolor=\"cyan\" >\n");
      out.write("                <tr><td>");
      out.print(num);
      out.write("</td><td>");
      out.print(name);
      out.write("</td><td>");
      out.print(content);
      out.write("</td><td>");
      out.print(recontent);
      out.write("</td>\n");
      out.write("                </tr>\n");
      out.write("            </table>\n");
      out.write("            ");
                    rs.next();                     i++;                   }                }            rs.close();            stmt.close();             conn.close();            
      out.write("\n");
      out.write("            <a href=\"handledisplay.jsp?page=");
      out.print(intPage-1);
      out.write("\" class=\"style3\">上一页</a>&nbps;\n");
      out.write("            <a href=\"handledisplay.jsp?page=");
      out.print(intPage+1);
      out.write("\" class=\"style3\">下一页</a>\n");
      out.write("            ");
            //String s=(String)session.getAttribute("rootid");            if(session.getAttribute("rootid")!=null){                out.print(                        "<form action=\"handledelete.jsp\" method=psot name=form>"+                            "<input type=\"text\" name=\"todel\" value=\"\">toDe" +                            "<input type=submit value=submit><br>"+                        "</form>"+                        "<form action=\"handlemodify.jsp\" method=psot name=form>"+                            "<input type=\"text\" name=\"tomod\" value=\"\">toMo<br>" +                                                        "<textarea name=newcontent cols=30 rows=4>"+"</textarea>"+                            "<input type=submit value=submit>"+                        "</form>"+                        "<form action=\"handlere.jsp\" method=\"psot\" name=form>"+                            "<input type=\"text\" name=\"tore\" value=\"\">toRe<br>" +                            "<textarea name=recontent cols=30 rows=4>"+"</textarea>"+                            "<input type=submit value=submit>"+                        "</form>"                                                    );            }        
      out.write("\n");
      out.write("    </body>\n");
      out.write("</html>\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        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 + -