search_0002ejsp_jsp.java
上传用户:top0756
上传日期:2022-08-11
资源大小:6501k
文件大小:6k
源码类别:

Jsp/Servlet

开发平台:

VBScript

  1. import java.sql.*;
  2. import javax.servlet.*;
  3. import javax.servlet.http.*;
  4. import javax.servlet.jsp.*;
  5. import org.apache.jasper.runtime.*;
  6. public class search_0002ejsp_jsp extends HttpJspBase {
  7.     static {
  8.     }
  9.     public search_0002ejsp_jsp( ) {
  10.     }
  11.     private static boolean _jspx_inited = false;
  12.     public final void _jspx_init() throws org.apache.jasper.runtime.JspException {
  13.     }
  14.     public void _jspService(HttpServletRequest request, HttpServletResponse  response)
  15.         throws java.io.IOException, ServletException {
  16.         JspFactory _jspxFactory = null;
  17.         PageContext pageContext = null;
  18.         HttpSession session = null;
  19.         ServletContext application = null;
  20.         ServletConfig config = null;
  21.         JspWriter out = null;
  22.         Object page = this;
  23.         String  _value = null;
  24.         try {
  25.             if (_jspx_inited == false) {
  26.                 synchronized (this) {
  27.                     if (_jspx_inited == false) {
  28.                         _jspx_init();
  29.                         _jspx_inited = true;
  30.                     }
  31.                 }
  32.             }
  33.             _jspxFactory = JspFactory.getDefaultFactory();
  34.             response.setContentType("text/html;charset=gb2312");
  35.             pageContext = _jspxFactory.getPageContext(this, request, response,
  36.              "", true, 8192, true);
  37.             application = pageContext.getServletContext();
  38.             config = pageContext.getServletConfig();
  39.             session = pageContext.getSession();
  40.             out = pageContext.getOut();
  41.             // HTML // begin [file="/search.jsp";from=(0,48);to=(1,0)]
  42.                 out.write("rn");
  43.             // end
  44.             // HTML // begin [file="/search.jsp";from=(1,29);to=(15,0)]
  45.                 out.write("<head>rn  <SCRIPT language="JavaScript">rnfunction a() {rnrntif(form1.keywords.value==""){rnttalert("用户名不能为空,请确定后重新输入");rnttform1.keywords.focus();rnttreturn false;rnt}rnrntreturn true;rn}</script></head>rn<HTML><BODY >rn<br>rn");
  46.             // end
  47.             // begin [file="/search.jsp";from=(15,2);to=(61,0)]
  48.                 
  49.                 Connection conn = null;
  50.                 Statement stmt = null;
  51.                 ResultSet rs = null;
  52.                 try{
  53.                  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  54.                 }
  55.                 catch(ClassNotFoundException ce){
  56.                  out.println(ce.getMessage());
  57.                 }
  58.                 request.setCharacterEncoding("GBK");
  59.                 String str = request.getParameter("keywords");
  60.                 if( str == null)
  61.                  str = "";
  62.                       else
  63.                 try{
  64.                  conn=DriverManager.getConnection("jdbc:odbc:dsn112");
  65.                  stmt=conn.createStatement();
  66.                         rs=stmt.executeQuery("SELECT * FROM student WHERE stu_id LIKE '%" + str + "%'");
  67.                         out.print("<table  width='100%' cellspacing='0' cellpadding='4' rules='all' bordercolor='#CC9966' border='1' id='dg_rxkb' style='background-color:White;border-color:#CC9966;border-width:1px;border-style:None;width:99%;border-collapse:collapse;'>");
  68.                          out.print("<tr bgcolor='EcEcff' align='center'><TD>姓名</TD>");
  69.                  out.print("<TD>学号</TD>");
  70.                  out.print("<TD>性别</TD>");
  71.                  out.print("<TD>专业</TD>");
  72.                                 out.print("<TD>民族</TD>");
  73.                                 out.print("<TD>政治面貌</TD>");
  74.                 
  75.                  while(rs.next()){
  76.                  out.print("<tr align='center'><TD>"+rs.getString("stu_name")+"</TD>");
  77.                  out.print("<TD>"+rs.getString("stu_id")+"</TD>");
  78.                  out.print("<TD>"+rs.getString("sex")+"</TD>");
  79.                  out.print("<TD>"+rs.getString("dept")+"</TD>");
  80.                                 out.print("<TD>"+rs.getString("mz")+"</TD>");
  81.                                  out.print("<TD>"+rs.getString("zzmm")+"</TD>");
  82.                  }
  83.                  out.print("</TABLE>");
  84.                 
  85.                 }
  86.                 catch(SQLException e){
  87.                  System.out.println(e.getMessage());
  88.                 }
  89.                 finally{
  90.                  stmt.close();
  91.                  conn.close();
  92.                 }
  93.                 
  94.             // end
  95.             // HTML // begin [file="/search.jsp";from=(61,2);to=(70,46)]
  96.                 out.write("rn<br><br>rn <FORM  name="form1" Action="search.jsp" Method="POST">rn <table  width="100%" cellspacing="0" cellpadding="4" rules="all" bordercolor="#CC9966" border="1" id="dg_rxkb" style="background-color:White;border-color:#CC9966;border-width:1px;border-style:None;width:99%;border-collapse:collapse;">rnrn<tr>rn      <td   colspan="2"><div align="center" ><font  size="5" color="red">查找信息</strong></font></div></td>rn    </tr>rn<tr ><td align="center"><font color="000000" size="4">请输入学号:</td>rn<td><INPUT Type="Text" Name="keywords" Value="");
  97.             // end
  98.             // begin [file="/search.jsp";from=(70,49);to=(70,52)]
  99.                 out.print(str);
  100.             // end
  101.             // HTML // begin [file="/search.jsp";from=(70,54);to=(79,0)]
  102.                 out.write(""></td></tr>rn<tr><td  height="35" colspan="2"><div align="center"><INPUT Type=Submit Value=" 查找" onClick="return a()"></td></tr></table>rn</FORM>rn<br>rn<br>rn<br>rn<p align=center>rn<img src="img/boshi.jpg">rn</BODY></HTML>rn");
  103.             // end
  104.         } catch (Throwable t) {
  105.             if (out != null && out.getBufferSize() != 0)
  106.                 out.clearBuffer();
  107.             if (pageContext != null) pageContext.handlePageException(t);
  108.         } finally {
  109.             if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
  110.         }
  111.     }
  112. }