user_delete.jsp

来自「一个JSP范例」· JSP 代码 · 共 42 行

JSP
42
字号
	<%@page contentType="text/html;charset=Gb2312" 
	  import="java.sql.*,java.util.Date,com.PoolBean"%>
	<JSP:useBean id="pool" scope="application" class="com.PoolBean"/>
	<%
	String strLoginUser = (String)session.getAttribute("LoginUser");
	if (strLoginUser == null || strLoginUser.length() == 0)	
		response.sendRedirect("Login.jsp");	
	%>
	<html>
	<head>
	  <title><h1>用户删除</h1></title>
	</head>
	<body>
	<center>
	 <font size=5 color=blue></font>用户删除</font>
	</center>
	<hr>
	<%
	try
	  {   com.PoolBean pool = new com.PoolBean();
	 	if (pool.getConnectionSize() == 0)
		{
			pool.initializePool();
		}	
		Connection con = null;
		Statement stmt = null;
		con = pool.getConnection();
		stmt= con.createStatement();
		String strDel ="delete from user where code='"+strLoginUser+"'";	
		stmt.executeUpdate(strDel);
		stmt.close();//关闭Statement对象
		pool.releaseConnection(con);
		response.sendRedirect("Login.jsp");
	  }
	   catch (Exception e)
	  {
	     out.println(e.getMessage());
	  }
	 %>
	</body>
	</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?