ReceiveBoxDelete.java
上传用户:liangcc
上传日期:2019-05-24
资源大小:4412k
文件大小:3k
源码类别:

WEB邮件程序

开发平台:

Java

  1. package com.softeem.webmail.receivemanage;
  2. import java.io.IOException;
  3. import javax.servlet.ServletException;
  4. import javax.servlet.http.HttpServlet;
  5. import javax.servlet.http.HttpServletRequest;
  6. import javax.servlet.http.HttpServletResponse;
  7. import javax.servlet.http.HttpSession;
  8. import com.softeem.webmail.dao.mail.DeleteMail;
  9. import com.softeem.webmail.dao.mail.Mail;
  10. import com.softeem.webmail.dao.mail.MailDAO;
  11. import com.softeem.webmail.dao.mail.MoveMail;
  12. public class ReceiveBoxDelete extends HttpServlet {
  13. public void doGet(HttpServletRequest request, HttpServletResponse response)
  14. throws ServletException, IOException {
  15. doPost(request, response);
  16. }
  17. public void doPost(HttpServletRequest request, HttpServletResponse response)
  18. throws ServletException, IOException {
  19. response.setContentType("text/html;charset=UTF-8");
  20. request.setCharacterEncoding("UTF-8");
  21. String box_name = request.getParameter("newBox");
  22. String method = request.getParameter("easyJWebCommand");
  23. System.out.println(method + "操作类型" + box_name + "<><><><>");
  24. // 邮件转移到其他邮箱或者删除
  25. if ("move".equalsIgnoreCase(method)) {
  26. String ids = request.getParameter("cid");
  27. String[] id = ids.split(",");
  28. for (String str : id) {
  29. int mail_id = Integer.parseInt(str);
  30. MoveMail.MoveMailByBoxname(box_name, mail_id);
  31. }
  32. response.sendRedirect("ReceiveBox");
  33. }
  34. // 彻底删除
  35. if ("del".equalsIgnoreCase(method)) {
  36. String ids = request.getParameter("cid");
  37. String[] id = ids.split(",");
  38. for (String str : id) {
  39. int mail_id = Integer.parseInt(str);
  40. DeleteMail.DeleteMailById(mail_id);
  41. }
  42. response.sendRedirect("ReceiveBox");
  43. }
  44. //邮件回复
  45. if ("reply".equalsIgnoreCase(method)) {
  46. String id = request.getParameter("cid");
  47. System.out.println(id+"==cid中的值为");
  48. int mail_id = Integer.parseInt(id);
  49. System.out.println(mail_id+"===mail_id的值为");
  50. Mail mail = MailDAO.getMailById(mail_id);
  51. HttpSession session = request.getSession(false);
  52. //放入session中的Mail对象  其别名为replymail
  53. session.setAttribute("replymail", mail);
  54. System.out.println("得到了mail");
  55. response.sendRedirect("write.jsp");
  56. }
  57. if("forward".equalsIgnoreCase(method)){
  58. String id = request.getParameter("cid");
  59. System.out.println(id+"==cid中的值为");
  60. int mail_id = Integer.parseInt(id);
  61. System.out.println(mail_id+"===mail_id的值为");
  62. Mail mail = MailDAO.getMailById(mail_id);
  63. HttpSession session = request.getSession(false);
  64. session.setAttribute("forwardmail", mail);
  65. System.out.println("得到了mail");
  66. response.sendRedirect("write.jsp");
  67. }
  68. }
  69. }