Main.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.login;
  8. import oa.sys.*;
  9. import oa.sys.Time;
  10. import oa.data.*;
  11. import java.util.*;
  12. import java.io.*;
  13. import java.sql.*;
  14. import javax.servlet.*;
  15. import javax.servlet.http.*;
  16. /**
  17.  ****************************************************
  18.  *类名称: View<br>
  19.  *类功能: 查看公告信息<br>
  20.  *创建: 白伟明 2004年9月23日<br>
  21.  ****************************************************
  22.  * To change the template for this generated type comment go to
  23.  * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
  24.  */
  25. public class Main extends HttpServlet{
  26. private String content;
  27. private int employeeid;
  28. private String time;
  29. private String title;
  30. private int id;
  31. private Statement stmt;
  32. private ResultSet rs;
  33. private RequestDispatcher dispatcher;
  34. private String sqls,sqls1;
  35. public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
  36. request.setCharacterEncoding("gb2312");
  37. response.setContentType("text/html; charset=gb2312");
  38. Db db=new Db();
  39. Str str=new Str();
  40. Time moon=new Time();
  41. sqls="SELECT * FROM affice ORDER BY afficeid DESC";
  42. sqls1="SELECT * FROM emexcellence WHERE time>='"+moon.getYear()+"-"+moon.getMonth()+"-01'";
  43. Collection colle=new ArrayList();
  44. Collection colla=new ArrayList();
  45. PrintWriter out=response.getWriter();
  46. try{
  47. stmt=db.getStmtread();
  48. rs=stmt.executeQuery(sqls);
  49. if(rs.next()){
  50. id=rs.getInt(1);
  51. title=rs.getString(2);
  52. time=rs.getString(3);
  53. employeeid=rs.getInt(4);
  54. content=rs.getString(5);
  55. title=str.outStr(title);
  56. content=str.outStr(content);
  57. Affice affice=new Affice();
  58. affice.setId(id);
  59. affice.setTitle(title);
  60. affice.setEmid(employeeid);
  61. affice.setTime(time);
  62. affice.setContent(content);
  63. colla.add(affice);
  64. }
  65. request.setAttribute("amsg",colla);
  66. db.close();
  67. stmt=db.getStmtread();
  68. rs=stmt.executeQuery(sqls1);
  69. while(rs.next()){
  70. Emex emex=new Emex();
  71. emex.setId(rs.getInt(1));
  72. emex.setEmid(rs.getInt(2));
  73. emex.setTime(rs.getString(3));
  74. emex.setLevelid(rs.getInt(4));
  75. emex.setDeid(rs.getInt(5));
  76. colle.add(emex);
  77. }
  78. db.close();
  79. request.setAttribute("emsg",colle);
  80. }catch(Exception e){
  81. db.close();
  82. e.printStackTrace();
  83. }finally{
  84. dispatcher=request.getRequestDispatcher("main.jsp");
  85. dispatcher.forward(request,response);
  86. }
  87. }
  88. public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
  89. doPost(request,response);
  90. }
  91. }