admin_del_bbs_action.jsp

来自「自己编写的jsp+mysql论坛系统,带后台系统.不是很完善,但是功能是完整的」· JSP 代码 · 共 61 行

JSP
61
字号
<%@ page language="java" contentType="text/html; charset=GBK"
	pageEncoding="GBK"%>
<%@page import="java.util.*,java.io.*,java.sql.*"%>
<%@ include file="../conn.jsp"%>
<%
	request.setCharacterEncoding("GBK");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=GBK">
	</head>
	<body>
		<%
			String username = "";
			int permission = 0;
			if ((null != session.getAttribute("adminlogin"))
					&& (null != session.getAttribute("permission"))) {
				username = session.getAttribute("adminlogin").toString();
				permission = Integer.parseInt(session
						.getAttribute("permission").toString());
				try {
					String strDo = "";
					String id = request.getParameter("id");
					if (id.equals("")) {
						response.sendRedirect("../error.jsp");
					} else {
						strDo = "SELECT * FROM " + tbbs + " WHERE id='" + id
								+ "'";
						System.out.print(strDo + "\n");
						rs = stmt.executeQuery(strDo);
						if (rs.next()) {
							rs.close();
							strDo = "DELETE FROM " + tbbs + " WHERE id='" + id
									+ "'";
							System.out.print(strDo + "\n");
							stmt.executeUpdate(strDo);
							//删除帖子回复数据
							strDo = "DELETE FROM " + treply + " WHERE postid='"
									+ id + "'";
							System.out.print(strDo + "\n");
							stmt.executeUpdate(strDo);
							response.sendRedirect("admin_all_bbs.jsp");
						} else {
							rs.close();
							response.sendRedirect("../error.jsp");
						}
					}
				} catch (Exception e) {
					e.printStackTrace();
					response.sendRedirect("../error.jsp");
				} finally {
					stmt.close();
					conn.close();
				}
			} else {
				response.sendRedirect("../error.jsp");
			}
		%>
	</body>
</html>

⌨️ 快捷键说明

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