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

📄 board_jsp.java

📁 用jsp实现在线留言!采用MVC三层架构!
💻 JAVA
字号:
package org.apache.jsp;

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

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

 String Forum_Name,Forum_Mastor,Forum_Id;
 String Note_Id,Note_Name,Replay_Name,Note_Author,Replay_Time;
  private static java.util.List _jspx_dependants;

  public Object getDependants() {
    return _jspx_dependants;
  }

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

    JspFactory _jspxFactory = null;
    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 {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html; charset=gb2312");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			"err.jsp", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("<html><script language=\"JavaScript\"></script></html>\r\n");
      out.write("<html>\r\n");
      out.write("<head>\r\n");
      out.write("<META NAME=\"keywords\" CONTENT=\"溢洋 溢洋论坛 xyworker@163.com java forum jsp forum\">\r\n");
      out.write("<META NAME=\"description\" CONTENT=\"溢洋 溢洋论坛 xyworker@163.com java forum jsp forum\">\r\n");
      out.write("<link rel='stylesheet' type='text/css' href='inc/FORUM.CSS'>\r\n");
      out.write("<script language=\"JavaScript\">\r\n");
      out.write("function Popup(url, window_name, window_width, window_height)\r\n");
      out.write("{ settings=\r\n");
      out.write("\"toolbar=no,location=no,directories=no,\"+\r\n");
      out.write("\"status=no,menubar=no,scrollbars=yes,\"+\r\n");
      out.write("\"resizable=yes,width=\"+window_width+\",height=\"+window_height;\r\n");
      out.write("\r\n");
      out.write("NewWindow=window.open(url,window_name,settings); }\r\n");
      out.write("\r\n");
      out.write("function icon(theicon) {\r\n");
      out.write("document.input.message.value += \" \"+theicon;\r\n");
      out.write("document.input.message.focus();\r\n");
      out.write("}\r\n");
      out.write("</script>\r\n");
      out.write("\r\n");
      out.write("<title>溢洋论坛</title>\r\n");
      out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\r\n");
      out.write("</head>\r\n");
      out.write("<body text=\"#0000ff\" align=\"center\">\r\n");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "inc/public.jsp", out, true);
      out.write("\r\n");
      out.write("<table width=\"760\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\r\n");
      yy.jdbc yy = null;
      synchronized (_jspx_page_context) {
        yy = (yy.jdbc) _jspx_page_context.getAttribute("yy", PageContext.PAGE_SCOPE);
        if (yy == null){
          yy = new yy.jdbc();
          _jspx_page_context.setAttribute("yy", yy, PageContext.PAGE_SCOPE);
        }
      }
      out.write('\r');
      out.write('\n');
      out.write('\r');
      out.write('\n');

 String fid=request.getParameter("fid");
 Connection con=yy.getConn();
 Statement  stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
 ResultSet rs=null;
 String sql="Select 论坛id,论坛名称,版主姓名 from 论坛栏目 Where 论坛id="+fid;
 rs=stmt.executeQuery(sql);
 //out.println(sql);
 while (rs.next())
 {
   Forum_Name=rs.getString("论坛名称");
   Forum_Id=rs.getString("论坛id");
   Forum_Mastor=rs.getString("版主姓名");
 }
 //  stmt.close();

      out.write("\r\n");
      out.write("\r\n");
      out.write("<tr>\r\n");
      out.write("    <td bgcolor=\"#ffffff\"  align=\"left\"><a href=\"default1.jsp\">首页</a>&gt;&gt;<a href=\"index.jsp\">溢洋论坛</a>&gt;&gt;");
      out.print(Forum_Name);
      out.write("</td>\r\n");
      out.write("    <td bgcolor=\"#ffffff\" class=\"post\" align=\"left\" width=\"330\">论坛版主:");
      out.print(Forum_Mastor);
      out.write("\r\n");
      out.write("    </td>\r\n");
      out.write("    <td><a href=\"post.jsp?fid=");
      out.print(Forum_Id);
      out.write("\"><img src=\"IMAGES/TOPIC.GIF\" border=\"0\" ></a></td>\r\n");
      out.write("  </tr></table>\r\n");
      out.write("\r\n");
      out.write("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"754\" align=\"center\" >\r\n");
      out.write("<tr><td bgcolor=\"#009ACE\">\r\n");
      out.write("\r\n");
      out.write("      <table border=\"0\" cellspacing=\"1\" cellpadding=\"6\" width=\"100%\" height=\"58\" align=\"center\">\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("    <tr bgcolor=\"#9CCFFF\">\r\n");
      out.write("          <td width=\"4%\" height=\"14\">&nbsp;</td>\r\n");
      out.write("          <td width=\"30%\" height=\"14\" bgcolor=\"#9CCFFF\">文章标题</td>\r\n");
      out.write("          <td width=\"8%\" align=\"center\" height=\"14\">新窗</td>\r\n");
      out.write("          <td width=\"10%\" align=\"center\" height=\"14\" bgcolor=\"#9CCFFF\">作者</td>\r\n");
      out.write("          <td width=\"10%\" align=\"center\" height=\"14\">回复数量</td>\r\n");
      out.write("          <td width=\"10%\" align=\"center\" height=\"14\">浏览数量</td>\r\n");
      out.write("          <td width=\"25%\" align=\"center\" height=\"14\">最后回复</td>\r\n");
      out.write("     </tr>\r\n");
      out.write('\r');
      out.write('\n');
      out.write(' ');

  int PageSize=10;
  int RecordCount=0;
  int PageCount=0;
  int ShowPage=1;


  sql="Select * from 贴子 Where 版块id="+fid+" And 回复id=0  order by 贴子id desc";
  // Statement  stmt=con.createStatement();
  rs=stmt.executeQuery(sql);

  rs.last();
  RecordCount=rs.getRow();
  PageCount=(RecordCount % PageSize==0)?(RecordCount/PageSize):(RecordCount/PageSize+1);
  String Page=request.getParameter("page");
  if (Page!=null)
  {
        ShowPage=Integer.parseInt(Page);
     if (ShowPage>PageCount)
        ShowPage=PageCount;
     else if(ShowPage<0)
        ShowPage=1;
  }else
        ShowPage=1;

if (RecordCount>0)
{
rs.absolute((ShowPage-1)*PageSize+1);
for (int i=1;i<PageSize;i++)
{
  Note_Id=rs.getString("贴子id");
  Note_Name=rs.getString("贴子名称");
  Note_Author=rs.getString("贴子作者");
  Replay_Name=rs.getString("回复用户");
  Replay_Time=rs.getString("回复时间");

      out.write("\r\n");
      out.write("         <tr bgcolor=\"#F7FBFF\">\r\n");
      out.write("          <td align=\"center\" height=\"16\"><img src=\"IMAGES/");
      out.print(rs.getString("贴子图片"));
      out.write(".GIF\" ></td>\r\n");
      out.write("          <td height=\"16\" bgcolor=\"#F7FBFF\"><a href=\"shownote.jsp?fid=");
      out.print(Forum_Id);
      out.write("&noteid=");
      out.print(Note_Id);
      out.write('"');
      out.write('>');
      out.print(Note_Name);
      out.write("</a>\r\n");
      out.write("            &nbsp; </td>\r\n");
      out.write("          <td align=\"center\" height=\"16\"><a href=\"shownote.jsp?fid=");
      out.print(Forum_Id);
      out.write("&noteid=");
      out.print(Note_Id);
      out.write("\" target=\"_blank\"><img src=\"image/newwin.gif\" border=\"0\"></a></td>\r\n");
      out.write("          <td align=\"center\" height=\"16\"><a href=\"member.jsp?member=");
      out.print(Note_Author);
      out.write('"');
      out.write('>');
      out.print(Note_Author);
      out.write("</a></td>\r\n");
      out.write("          <td align=\"center\" height=\"16\">");
      out.print(rs.getString("回复次数"));
      out.write("</td>\r\n");
      out.write("          <td align=\"center\" height=\"16\">");
      out.print(rs.getString("点击次数"));
      out.write("</td>\r\n");
      out.write("          <td height=\"16\">时间:");
      out.print(Replay_Time.substring(0,16));
      out.write("<br />\r\n");
      out.write("            作者: <a href=\"member.jsp?member=");
      out.print(Replay_Name);
      out.write('"');
      out.write('>');
      out.print(Replay_Name);
      out.write("</a></td>\r\n");
      out.write("</tr>\r\n");

if (!rs.next())
break;
}
}
else
{


      out.write("\r\n");
      out.write("        <tr bgcolor=\"#F7FBFF\">\r\n");
      out.write("          <td align=\"center\"  height=\"16\" colspan=\"7\" width=\"633\">对不起,该论坛暂时没有贴子 </td>\r\n");
      out.write("        </tr>\r\n");

}

      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("</table>\r\n");
      out.write("</td></tr>\r\n");
      out.write("</table>\r\n");
      out.write("<br>\r\n");
      out.write("<table width=\"733\" cellspacing=\"0\" cellpadding=\"0\"  height=\"2\" align=\"center\">\r\n");
      out.write("  <tr>\r\n");
      out.write("    <td  height=\"2\" valign=\"top\">&nbsp; </td>\r\n");
      out.write("<td  align=\"right\" height=\"2\">\r\n");
      out.write("<form method=\"POST\" action=\"board.jsp\">\r\n");
      out.write("<p><input type=\"hidden\" name=\"fid\" size=\"20\" value='");
      out.print(Forum_Id);
      out.write("'></p>\r\n");
      out.write("<p>现在是第 <font color=black >");
      out.print(ShowPage);
      out.write("</font> 页 转到<select size=\"1\" name=\"page\">\r\n");

for (int i=1;i<=PageCount;i++)
{
    out.println(" <option value="+i+">"+i+"页</option>");
}

      out.write("\r\n");
      out.write("</select>\r\n");
      out.write("<input type=\"submit\" value=\"go\" name=\"B1\"></p>\r\n");
      out.write("</form>\r\n");
      out.write("</td></tr>\r\n");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "inc/jumpboard.jsp", out, true);
      out.write("\r\n");
      out.write("</table>\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("</body></html>\r\n");
      out.write("\r\n");
      out.write("<html><script language=\"JavaScript\"></script></html>\r\n");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "inc/online.jsp", out, true);
    } 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 {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}

⌨️ 快捷键说明

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