search.jsp~33~
资源名称:JSP02.rar [点击查看]
上传用户:top0756
上传日期:2022-08-11
资源大小:6501k
文件大小:3k
源码类别:
Jsp/Servlet
开发平台:
VBScript
- <%@page contentType="text/html;charset=gb2312"%>
- <%@page import="java.sql.*"%><head>
- <SCRIPT language="JavaScript">
- function a() {
- if(form1.keywords.value==""){
- alert("用户名不能为空,请确定后重新输入");
- form1.keywords.focus();
- return false;
- }
- return true;
- }</script></head>
- <HTML><BODY >
- <br>
- <%
- Connection conn = null;
- Statement stmt = null;
- ResultSet rs = null;
- try{
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- }
- catch(ClassNotFoundException ce){
- out.println(ce.getMessage());
- }
- request.setCharacterEncoding("GBK");
- String str = request.getParameter("keywords");
- if( str == null)
- str = "";
- else
- try{
- conn=DriverManager.getConnection("jdbc:odbc:dsn112");
- stmt=conn.createStatement();
- rs=stmt.executeQuery("SELECT * FROM student WHERE stu_id LIKE '%" + str + "%'");
- 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;'>");
- out.print("<tr bgcolor='EcEcff' align='center'><TD>姓名</TD>");
- out.print("<TD>性别</TD>");
- out.print("<TD>年龄</TD>");
- out.print("<TD>专业</TD>");
- out.print("<TD>入学时间</TD>");
- out.print("<TD>联系方式</TD>");
- out.print("<TD>地址</TD></TR>");
- while(rs.next()){
- out.print("<tr align='center'><TD>"+rs.getString("name")+"</TD>");
- out.print("<TD>"+rs.getString("sex")+"</TD>");
- out.print("<TD>"+rs.getString("age")+"</TD>");
- out.print("<TD>"+rs.getString("dept")+"</TD>");
- out.print("<TD>"+rs.getString("ruxdate")+"</TD>");
- out.print("<TD>"+rs.getString("tel")+"</TD>");
- out.print("<TD>"+rs.getString("address")+"</TD></TR>");
- }
- out.print("</TABLE>");
- }
- catch(SQLException e){
- System.out.println(e.getMessage());
- }
- finally{
- stmt.close();
- conn.close();
- }
- %>
- <br><br>
- <FORM name="form1" Action="search.jsp" Method="POST">
- <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;">
- <tr>
- <td bgcolor="EcEcff" colspan="2"><div align="center" ><font size="5" color="red">查找信息</strong></font></div></td>
- </tr>
- <tr ><td><font color="000000" size="4">输入姓名关键字:</td>
- <td><INPUT Type="Text" Name="keywords" Value="<%=str%>"></td></tr>
- <tr><td height="35" colspan="2"><div align="center"><INPUT Type=Submit Value=" 查找" onClick="return a()"></td></tr></table>
- </FORM>
- </BODY></HTML>