Delete_UserById.java
上传用户:huaxinghn
上传日期:2022-04-20
资源大小:673k
文件大小:1k
源码类别:

Ajax

开发平台:

JavaScript

  1. package lilin.servlet;
  2. import java.io.IOException;
  3. import java.io.PrintWriter;
  4. import java.sql.SQLException;
  5. import javax.servlet.ServletException;
  6. import javax.servlet.http.HttpServlet;
  7. import javax.servlet.http.HttpServletRequest;
  8. import javax.servlet.http.HttpServletResponse;
  9. import lilin.dao.DB;
  10. public class Delete_UserById extends HttpServlet {
  11. public void doGet(HttpServletRequest request, HttpServletResponse response)
  12. throws ServletException, IOException {
  13. this.doPost(request, response);
  14. }
  15. public void doPost(HttpServletRequest request, HttpServletResponse response)
  16. throws ServletException, IOException {
  17. response.setContentType("text/html;charset=utf-8");
  18. PrintWriter out = response.getWriter();
  19. String id = request.getParameter("id");
  20. int tid = Integer.parseInt(id);
  21. DB db_ref = null;
  22. try {
  23. db_ref = new DB();
  24. boolean is_true = db_ref.delete_User(tid);
  25. if(is_true){
  26. out.println(1);
  27. }
  28. } catch (ClassNotFoundException e) {
  29. // TODO Auto-generated catch block
  30. e.printStackTrace();
  31. } catch (SQLException e) {
  32. // TODO Auto-generated catch block
  33. e.printStackTrace();
  34. }finally{
  35. db_ref.closeAll();
  36. }
  37. out.flush();
  38. out.close();
  39. }
  40. }