Update_User.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.bean.User;
  10. import lilin.dao.DB;
  11. public class Update_User extends HttpServlet {
  12. public void doGet(HttpServletRequest request, HttpServletResponse response)
  13. throws ServletException, IOException {
  14. this.doPost(request, response);
  15. }
  16. public void doPost(HttpServletRequest request, HttpServletResponse response)
  17. throws ServletException, IOException {
  18. request.setCharacterEncoding("utf-8");
  19. response.setContentType("text/html;charset=utf-8");
  20. PrintWriter out = response.getWriter();
  21. User u = new User();
  22. DB db_ref = null;
  23. String id = request.getParameter("id");
  24. String value = request.getParameter("name");
  25. String type = request.getParameter("type");
  26. try {
  27. db_ref = new DB();
  28. boolean is_true = db_ref.update_User(Integer.parseInt(id),type,value);
  29. if(is_true){
  30. out.println(1);
  31. }else{
  32. out.println(0);
  33. }
  34. } catch (ClassNotFoundException e) {
  35. // TODO Auto-generated catch block
  36. e.printStackTrace();
  37. } catch (SQLException e) {
  38. // TODO Auto-generated catch block
  39. e.printStackTrace();
  40. }finally{
  41. db_ref.closeAll();
  42. }
  43. out.flush();
  44. out.close();
  45. }
  46. }