Delete_UserById.java
上传用户:huaxinghn
上传日期:2022-04-20
资源大小:673k
文件大小:1k
- package lilin.servlet;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.sql.SQLException;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import lilin.dao.DB;
- public class Delete_UserById extends HttpServlet {
-
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- this.doPost(request, response);
-
- }
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- response.setContentType("text/html;charset=utf-8");
- PrintWriter out = response.getWriter();
- String id = request.getParameter("id");
- int tid = Integer.parseInt(id);
- DB db_ref = null;
- try {
- db_ref = new DB();
- boolean is_true = db_ref.delete_User(tid);
-
- if(is_true){
- out.println(1);
- }
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }finally{
- db_ref.closeAll();
- }
-
- out.flush();
- out.close();
- }
- }