Send.java
上传用户:sxwtmm
上传日期:2022-08-11
资源大小:2183k
文件大小:3k
源码类别:

OA系统

开发平台:

Java

  1. /*
  2.  * Created on 2004-9-24
  3.  *
  4.  * To change the template for this generated file go to
  5.  * Window>Preferences>Java>Code Generation>Code and Comments
  6.  */
  7. package com.info;
  8. import oa.sys.*;
  9. import oa.sys.Time;
  10. import java.io.IOException;
  11. import java.io.PrintWriter;
  12. import java.sql.*;
  13. import javax.servlet.*;
  14. import javax.servlet.http.*;
  15. /**
  16.  ****************************************************
  17.  *类名称: Send<br>
  18.  *类功能: 发送短消息<br>
  19.  *创建: 白伟明 2004年10月11日<br>
  20.  ****************************************************
  21.  * To change the template for this generated type comment go to
  22.  * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
  23.  */
  24. public class Send extends HttpServlet{
  25. private int acceptid;
  26. private HttpSession session=null;
  27. private ResultSet rs=null;
  28. private Statement stmt=null;
  29. private String title,content,sqli,sqls;
  30. private int temp=0,id;
  31. public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
  32. request.setCharacterEncoding("gb2312");
  33. response.setContentType("text/html; charset=gb2312");
  34. Str str=new Str();
  35. Db db=new Db();
  36. Time time=new Time();
  37. PrintWriter out=response.getWriter();
  38. session=request.getSession();
  39. id=Integer.parseInt((String)session.getAttribute("id"));
  40. try{
  41. acceptid=Integer.parseInt((String)request.getParameter("acceptid"));
  42. }catch(Exception e){
  43. e.printStackTrace();
  44. }
  45. title=request.getParameter("title");
  46. content=request.getParameter("content");
  47. title=str.inStr(title);
  48. content=str.inStr(content);
  49. sqli="INSERT INTO info(title,time,sendter,accepter,content) VALUES('"+title+"','"+time.getYMDHMS()+"',"+id
  50. +","+acceptid+",'"+content+"')";
  51. sqls="SELECT * FROM eminfo WHERE employeeid="+acceptid;
  52. try {
  53. stmt=db.getStmtread();
  54. rs=stmt.executeQuery(sqls);
  55. if(rs.next()){
  56. rs.close();
  57. stmt.close();
  58. stmt=db.getStmt();
  59. temp=stmt.executeUpdate(sqli);
  60. if(temp>0){
  61. request.setAttribute("msg","发送成功");
  62. }else{
  63. request.setAttribute("msg","发送失败");
  64. }
  65. db.close();
  66. }else{
  67. request.setAttribute("msg","接收人序号不存在");
  68. db.close();
  69. }
  70. } catch (SQLException e) {
  71. e.printStackTrace();
  72. }finally{
  73. RequestDispatcher dispatcher=request.getRequestDispatcher("send.jsp");
  74. dispatcher.forward(request,response);
  75. }
  76. }
  77. public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
  78. doPost(request,response);
  79. }
  80. }