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

WEB邮件程序

开发平台:

Java

  1. package com.softeem.webmail.draftbox;
  2. import java.io.IOException;
  3. import java.io.PrintWriter;
  4. import javax.servlet.ServletException;
  5. import javax.servlet.http.HttpServlet;
  6. import javax.servlet.http.HttpServletRequest;
  7. import javax.servlet.http.HttpServletResponse;
  8. import javax.servlet.http.HttpSession;
  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 ManageDraftServlet 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");
  20. PrintWriter out = response.getWriter();
  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 str = request.getParameter("cid");
  27. System.out.println(str+"<><><>");
  28. String []ss = str.split(",");
  29. for(String id:ss){
  30. int mail_id = Integer.parseInt(id);
  31. MoveMail.MoveMailByBoxname(box_name, mail_id);
  32. }
  33. response.sendRedirect("DraftboxServlet");
  34. }
  35. //转发
  36. if("forword".equalsIgnoreCase(method)){
  37. String id = request.getParameter("cid");
  38. System.out.println(id+"==cid中的值为");
  39. int mail_id = Integer.parseInt(id);
  40. System.out.println(mail_id+"===mail_id的值为");
  41. Mail mail = MailDAO.getMailById(mail_id);
  42. HttpSession session = request.getSession(false);
  43. session.setAttribute("forwardmail", mail);
  44. System.out.println("得到了mail");
  45. response.sendRedirect("write.jsp");
  46. }
  47. //回复
  48. if("reply".equalsIgnoreCase(method)){
  49. String id = request.getParameter("cid");
  50. System.out.println(id+"==cid中的值为");
  51. int mail_id = Integer.parseInt(id);
  52. System.out.println(mail_id+"===mail_id的值为");
  53. Mail mail = MailDAO.getMailById(mail_id);
  54. HttpSession session = request.getSession(false);
  55. //放入session中的Mail对象  其别名为replymail
  56. session.setAttribute("replymail", mail);
  57. System.out.println("得到了mail");
  58. response.sendRedirect("write.jsp");
  59. }
  60. }
  61. }