UserList.jsp
上传用户:jhoneliu
上传日期:2022-07-31
资源大小:950k
文件大小:2k
- <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
- <link href="css/mycss.css" rel="stylesheet" type="text/css">
- </head>
- <body>
- <%
- if(session.getAttribute("userid")== null || session.getAttribute("userid").equals(""))
- {
- response.sendRedirect("index.jsp");
- }
- %>
- <jsp:include flush="true" page="head.jsp"/><br /><br /><br /><br />
- <table width="713" border="0" align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td><a href="UserAdd.jsp">新增</a></td>
- </tr>
- </table>
- <%
- String driver = "sun.jdbc.odbc.JdbcOdbcDriver"; //驱动程序,见第十四章
- String url="jdbc:odbc:stud";//数据库连接语句,见第十四章
- String userID="sa",pwd="",sql="";
- try{
- Class.forName(driver);//调入JDBC-ODBC桥的驱动程序
- Connection conn = DriverManager.getConnection(url,userID,pwd);//建立与数据的连接
- //request对象见第四章
- sql = "select * from users";
- Statement stmt = conn.createStatement();//建立Statement的实例,相当于创建一个查询分析器的运行环境
- ResultSet rs = stmt.executeQuery(sql); //把查询结果放入ResultSet对象
- %>
- <table width="713" border="1" align="center" cellpadding="3" cellspacing="1">
- <tr>
- <td width="157"><div align="center">登录名称</div></td>
- <td width="188"><div align="center">登录密码</div></td>
- <td width="173"><div align="center">修改密码</div></td>
- <td width="156"><div align="center">删除资料</div></td>
- </tr>
- <%
- String user_id="";
- while(rs.next()){
- user_id=rs.getString("UserID");
- %>
- <tr>
- <td><div align="center"><%=user_id%></div></td>
- <td><div align="center"><%=rs.getString("Password")%></div></td>
- <td><div align="center"><a href="changePwd.jsp?userid=<%=user_id%>">修改密码</a></div></td>
- <td><div align="center"><a href="userDel.jsp?userid=<%=user_id%>" onclick="return check();">删除资料</a></div></td>
- </tr>
- <% }
- }catch(Exception e){
- System.out.println(e.getMessage());
- } %>
- </table>
- <p> </p>
- <p>
- </p>
- <br><br><br>
- <jsp:include flush="true" page="bottom.jsp"/>
- </body>
- </html>
- <script language="javascript">
- function check(){
- if(confirm("删除确认")){
- return true;
- }
- return false;
- }
- </script>