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

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.affice;
  8. import oa.sys.*;
  9. import oa.data.*;
  10. import java.util.*;
  11. import java.io.*;
  12. import java.sql.*;
  13. import javax.servlet.*;
  14. import javax.servlet.http.*;
  15. /**
  16.  ****************************************************
  17.  *类名称: View<br>
  18.  *类功能: 查看公告信息<br>
  19.  *创建: 白伟明 2004年9月23日<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 View extends HttpServlet{
  25. private int employeeid;
  26. private String time;
  27. private Statement stmt;
  28. private ResultSet rs;
  29. private String title,content;
  30. private RequestDispatcher dispatcher;
  31. private int id=0;
  32. public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
  33. request.setCharacterEncoding("gb2312");
  34. response.setContentType("text/html; charset=gb2312");
  35. Db db=new Db();
  36. Str str=new Str();
  37. Collection ret=new ArrayList();
  38. PrintWriter out=response.getWriter();
  39. try{
  40. stmt=db.getStmtread();
  41. rs=stmt.executeQuery("SELECT * FROM affice");
  42. while(rs.next()){
  43. id=rs.getInt(1);
  44. title=rs.getString(2);
  45. time=rs.getString(3);
  46. employeeid=rs.getInt(4);
  47. content=rs.getString(5);
  48. title=str.outStr(title);
  49. content=str.outStr(content);
  50. Affice affice=new Affice();
  51. affice.setId(id);
  52. affice.setTitle(title);
  53. affice.setEmid(employeeid);
  54. affice.setTime(time);
  55. affice.setContent(content);
  56. ret.add(affice);
  57. }
  58. request.setAttribute("msg",ret);
  59. }catch(Exception e){
  60. e.printStackTrace();
  61. }finally{
  62. db.close();
  63. dispatcher=request.getRequestDispatcher("view.jsp");
  64. dispatcher.forward(request,response);
  65. }
  66. }
  67. public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
  68. doPost(request,response);
  69. }
  70. }