majorList.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">
- </head>
- <body>
- <%
- if(session.getAttribute("userid")== null || session.getAttribute("userid").equals(""))
- {
- response.sendRedirect("index.jsp");
- }
- %>
- <jsp:include flush="true" page="head.jsp"/><br />
- <p align="center"><strong><font size="4" color="#FF0000"">专业资料列表</font></strong></p>
- <table width="768" border="0" align="center" cellpadding="3" cellspacing="1">
- <tr><td><a href="MajorAdd.jsp">新增</a></td></tr>
- </tr>
- </table>
- <table width="768" border="1" align="center" cellpadding="3" cellspacing="1">
- <tr>
- <td><div align="center">专业编号</div></td>
- <td><div align="center">专业名称 </div></td>
- <td><div align="center">所属分院</div></td>
- <td><div align="center">修改资料</div></td>
- <td><div align="center">删除资料</div></td>
- </tr>
- <%
- 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 m.majorid,m.majorname,d.depname from major m left outer join department d on m.depid=d.depid";
- Statement stmt = conn.createStatement();//建立Statement的实例,相当于创建一个查询分析器的运行环境
- ResultSet rs = stmt.executeQuery(sql); //把查询结果放入ResultSet对象
- String majorId="",majorName="",depname="";
- while(rs.next()){
- majorId=rs.getString("majorid");
- majorName=rs.getString("majorname");
- depname=rs.getString("depname");
- %>
- <tr>
- <td><div align="center"><%=majorId%></div></td>
- <td><div align="center"><%=majorName%></div></td>
- <td><div align="center"><%=depname%></div></td>
- <td><div align="center"><a href="majorEdit.jsp?majorId=<%=majorId%>">修改资料</a></div></td>
- <td><div align="center"><a href="majorDel.jsp?majorId=<%=majorId%>" onclick="return check();">删除资料</a></div></td>
- </tr>
- <%}
- }catch(Exception e){
- System.out.println(e.getMessage());
- }
- %>
- </table>
- <br />
- <jsp:include flush="true" page="bottom.jsp"/>
- </body>
- </html>
- <script language="javascript">
- function check()
- {
- if(confirm("删除确认"))
- {
- return true;
- }
- return false;
- }
- </script>