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

OA系统

开发平台:

Java

  1. /*
  2.  * Created on 2004-9-25
  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.em;
  8. import oa.sys.*;
  9. import oa.data.*;
  10. import java.io.*;
  11. import java.sql.*;
  12. import java.util.*;
  13. import javax.servlet.*;
  14. import javax.servlet.http.*;
  15. /**
  16.  ****************************************************
  17.  *类名称: View<br>
  18.  *类功能: 浏览员工信息<br>
  19.  *创建: 白伟明 2004年9月27日<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 Statement stmt=null;
  26. private ResultSet rs=null;
  27. private Statement stmt1=null;
  28. private ResultSet rs1=null;
  29. private String name,birthday,dep,job,state,learn,post,tel,addr,sql="SELECT * FROM eminfo";
  30. private RequestDispatcher dispatcher=null;
  31. private HttpSession session=null;
  32. private int deid,jobid,stateid,sex,id;
  33. private PrintWriter out=null;
  34. public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
  35. request.setCharacterEncoding("gb2312");
  36. response.setContentType("text/html; charset=gb2312");
  37. out=response.getWriter();
  38. session=request.getSession();
  39. Collection coll=new ArrayList();
  40. //获取数据
  41. Db db=new Db();
  42. Str str=new Str();
  43. try{
  44. stmt=db.getStmtread();
  45. rs=stmt.executeQuery(sql);
  46. while(rs.next()){
  47. id=rs.getInt(1);
  48. name=rs.getString(2);
  49. sex=rs.getInt(3);
  50. birthday=rs.getString(4);
  51. learn=rs.getString(5);
  52. post=rs.getString(6);
  53. deid=rs.getInt(7);
  54. jobid=rs.getInt(8);
  55. tel=rs.getString(9);
  56. addr=rs.getString(10);
  57. stateid=rs.getInt(11);
  58. dep=db.IdtoDo("Name","department WHERE departmentid="+deid);
  59. job=db.IdtoDo("Name","job WHERE jobid="+jobid);
  60. state=db.IdtoDo("Name","emstate WHERE stateid="+stateid);
  61. //字符转换
  62. name=str.outStr(name);
  63. birthday=birthday.substring(0,10);
  64. dep=str.outStr(dep);
  65. job=str.outStr(job);
  66. state=str.outStr(state);
  67. learn=str.outStr(learn);
  68. post=str.outStr(post);
  69. tel=str.outStr(tel);
  70. addr=str.outStr(addr);
  71. Eminfo eminfo=new Eminfo();
  72. eminfo.setId(id);
  73. eminfo.setName(name);
  74. eminfo.setSex(sex);
  75. eminfo.setBirthday(birthday);
  76. eminfo.setLearn(learn);
  77. eminfo.setPost(post);
  78. eminfo.setDepartment(dep);
  79. eminfo.setJob(job);
  80. eminfo.setTel(tel);
  81. eminfo.setAddr(addr);
  82. eminfo.setState(state);
  83. coll.add(eminfo);
  84. }
  85. }catch(Exception e){
  86. e.printStackTrace();
  87. }finally{
  88. db.close();
  89. request.setAttribute("msg",coll);
  90. dispatcher=request.getRequestDispatcher("view.jsp");
  91. dispatcher.forward(request,response);
  92. }
  93. }
  94. public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
  95. doPost(request,response);
  96. }
  97. }