Select.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.job;
  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.  *类名称: Select<br>
  18.  *类功能: 查找职位信息<br>
  19.  *创建: 白伟明 2004年9月25日<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 Select  extends HttpServlet{
  25. private Statement stmt=null;
  26. private ResultSet rs=null;
  27. private String name,explain,sqls,flag;
  28. private RequestDispatcher dispatcher;
  29. private int id=0;
  30. public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
  31. request.setCharacterEncoding("gb2312");
  32. response.setContentType("text/html; charset=gb2312");
  33. Db db=new Db();
  34. Str str=new Str();
  35. PrintWriter out=response.getWriter();
  36. try{
  37. id=Integer.parseInt((String)request.getParameter("id"));
  38. }catch(Exception e){
  39. }
  40. flag=request.getParameter("flag");
  41. sqls="SELECT * FROM job WHERE jobid="+id;
  42. Collection ret=new ArrayList();
  43. try{
  44. stmt=db.getStmtread();
  45. rs=stmt.executeQuery(sqls);
  46. //判断是否有数据
  47. if(rs.next()){
  48. rs.beforeFirst();
  49. if(rs.next()){
  50. id=rs.getInt(1);
  51. name=rs.getString(2);
  52. explain=rs.getString(3);
  53. name=str.outStr(name);
  54. explain=str.outStr(explain);
  55. Department dep=new Department();
  56. dep.setId(id);
  57. dep.setName(name);
  58. dep.setExplain(explain);
  59. ret.add(dep);
  60. }
  61. request.setAttribute("msg2",ret);
  62. }
  63. }catch(Exception e){
  64. e.printStackTrace();
  65. }finally{
  66. db.close();
  67. if(flag!=null){
  68. dispatcher=request.getRequestDispatcher("del.jsp");
  69. }else{
  70. dispatcher=request.getRequestDispatcher("change.jsp");
  71. }
  72. dispatcher.forward(request,response);
  73. }
  74. }
  75. public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
  76. doPost(request,response);
  77. }
  78. }