search.jsp~39~
上传用户:top0756
上传日期:2022-08-11
资源大小:6501k
文件大小:3k
源码类别:

Jsp/Servlet

开发平台:

VBScript

  1. <%@page contentType="text/html;charset=gb2312"%>
  2. <%@page import="java.sql.*"%><head>
  3.   <SCRIPT language="JavaScript">
  4. function a() {
  5. if(form1.keywords.value==""){
  6. alert("用户名不能为空,请确定后重新输入");
  7. form1.keywords.focus();
  8. return false;
  9. }
  10. return true;
  11. }</script></head>
  12. <HTML><BODY >
  13. <br>
  14. <%
  15. Connection conn = null;
  16. Statement stmt = null;
  17. ResultSet rs = null;
  18. try{
  19. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  20. }
  21. catch(ClassNotFoundException ce){
  22. out.println(ce.getMessage());
  23. }
  24. request.setCharacterEncoding("GBK");
  25. String str = request.getParameter("keywords");
  26. if( str == null)
  27. str = "";
  28.       else
  29. try{
  30. conn=DriverManager.getConnection("jdbc:odbc:dsn112");
  31. stmt=conn.createStatement();
  32.         rs=stmt.executeQuery("SELECT * FROM student WHERE stu_id LIKE '%" + str + "%'");
  33.         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;'>");
  34.          out.print("<tr bgcolor='EcEcff' align='center'><TD>姓名</TD>");
  35. out.print("<TD>学号</TD>");
  36. out.print("<TD>性别</TD>");
  37. out.print("<TD>专业</TD>");
  38.                 out.print("<TD>民族</TD>");
  39.                 out.print("<TD>政治面貌</TD>");
  40. while(rs.next()){
  41. out.print("<tr align='center'><TD>"+rs.getString("stu_name")+"</TD>");
  42. out.print("<TD>"+rs.getString("stu_id")+"</TD>");
  43. out.print("<TD>"+rs.getString("sex")+"</TD>");
  44. out.print("<TD>"+rs.getString("dept")+"</TD>");
  45.                 out.print("<TD>"+rs.getString("mz")+"</TD>");
  46.                  out.print("<TD>"+rs.getString("zzmm")+"</TD>");
  47. }
  48. out.print("</TABLE>");
  49. }
  50. catch(SQLException e){
  51. System.out.println(e.getMessage());
  52. }
  53. finally{
  54. stmt.close();
  55. conn.close();
  56. }
  57. %>
  58. <br><br>
  59.  <FORM  name="form1" Action="search.jsp" Method="POST">
  60.  <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;">
  61. <tr>
  62.       <td   colspan="2"><div align="center" ><font  size="5" color="red">查找信息</strong></font></div></td>
  63.     </tr>
  64. <tr ><td><font color="000000" size="4">请输入学号:</td>
  65. <td><INPUT Type="Text" Name="keywords" Value="<%=str%>"></td></tr>
  66. <tr><td  height="35" colspan="2"><div align="center"><INPUT Type=Submit Value=" 查找" onClick="return a()"></td></tr></table>
  67. </FORM>
  68. <br>
  69. <br>
  70. <br>
  71. <p align=center>
  72. <img src="img/boshi.jpg">
  73. </BODY></HTML>