📄 y2_jsp.java
字号:
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;
public final class y2_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
int totnum;
private static java.util.Vector _jspx_dependants;
public java.util.List 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,
"", 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("<html>\n");
out.write("<head>\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\n");
out.write("<title>查看投票结果</title>\n");
out.write("</head>\n");
out.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"css2.css\">\n");
out.write("<body>\n");
out.write("<div id=\"container\">\n");
out.write(" <div id=\"Header\">\n");
out.write(" </div>\n");
out.write('\n');
Statement stmt=null; PreparedStatement pstmt=null; String sql="select sum(vnum) as totnum from vote"; //加载JDBC-ODBC桥驱动 try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //定义JDBC URL }catch (Exception e) { out.println(e.getMessage()); } try{ String url = "jdbc:odbc:s"; //得到与数据库的连接 Connection con = DriverManager.getConnection(url); //显示UPL和连接信息 System.out.print("URL:" + url); System.out.print("Connection:" + con); //得到一个Statement对象 stmt = con.createStatement(); //执行SQL语句 System.out.print("SQL:" + sql); ResultSet p = stmt.executeQuery(sql);
out.write("\n");
out.write("<table width=\"100%\" cellpadding=\"0\" cellspacing=\"1\" align=\"center\">\n");
out.write("<tr bgcolor=\"#99ccff\">\n");
out.write("<td align=\"center\">序 号</td>\n");
out.write("<td align=\"center\">选 项</td>\n");
out.write("<td align=\"center\">投 票 率</td>\n");
out.write("</tr>\n");
while(p.next()){ totnum = p.getInt("totnum");} } catch (Exception e) {}
out.write('\n');
out.write(' ');
String ssql="select * from vote"; //加载JDBC-ODBC桥驱动 try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //定义JDBC URL }catch (Exception e) { out.println(e.getMessage()); } try{ String url = "jdbc:odbc:s"; //得到与数据库的连接 Connection con = DriverManager.getConnection(url); //显示UPL和连接信息 System.out.print("URL:" + url); System.out.print("Connection:" + con); //得到一个Statement对象 stmt = con.createStatement(); //执行SQL语句 System.out.print("SQL:" + ssql); ResultSet g = stmt.executeQuery(ssql); int i=1;while(g.next()){int vnum = g.getInt("vnum");
out.write("\n");
out.write("<tr>\n");
out.write("<td height=\"22\" align=\"center\">\n");
out.write("[");
out.print(i);
out.write("]</td>\n");
out.write("<td height=\"27\" align=\"center\">\n");
out.print(g.getString("vname"));
out.write("\n");
out.write("</td>\n");
out.write("<td>\n");
out.write("投票率:<img src=\"1.bmp\" width=\"");
out.print(Math.floor(vnum*200/totnum));
out.write("\" height=\"10\"> ");
out.print(Math.floor(vnum*100/totnum));
out.write("% [得:");
out.print(vnum);
out.write("票 共:");
out.print(totnum);
out.write("票]</td>\n");
out.write("</tr>\n");
i++;} } catch (Exception e) {}
out.write("\n");
out.write("<tr bgcolor=\"#99ccff\">\n");
out.write("<td colspan=\"3\" height=\"18\" align=\"center\">[<a href=\"y1.jsp\">返回投票页</a>]</td>\n");
out.write("</tr>\n");
out.write("</table>\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)
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 + -