Пример #1
0
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    try {
      response.setContentType("text/html;charset=UTF-8");
      PrintWriter out = response.getWriter();
      dbConnect conn = new dbConnect();
      session = request.getSession(true);

      ArrayList list2 = new ArrayList();

      String query = "select * from dicname";
      System.out.println("query " + query);
      try {
        conn.state = conn.connect.createStatement();
      } catch (SQLException ex) {
        Logger.getLogger(CountyServlet.class.getName()).log(Level.SEVERE, null, ex);
      }
      conn.rs = conn.state.executeQuery(query);
      if (list2 != null && list2.size() > 0) {
        list2.clear();
      }

      while (conn.rs.next()) {

        DICBean DB = new DICBean();
        DB.setDICID(conn.rs.getInt(1));
        DB.setDICNAME(conn.rs.getString(2));
        DB.setDISTRICTID(conn.rs.getInt(3));

        list2.add(DB);
        System.out.println(DB.getDICID());
        System.out.println(DB.getDICNAME());
      }
      session.setAttribute("list2", list2);
      String nextJSP = "/Maintenance/DIC.jsp";

      RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
      dispatcher.forward(request, response);
      conn.connect.close();
      System.out.println("Disconnected from database");
    } catch (SQLException ex) {
      Logger.getLogger(DICServlet.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
Пример #2
0
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    try {
      response.setContentType("text/html;charset=UTF-8");
      PrintWriter out = response.getWriter();
      dbConnect conn = new dbConnect();
      session = request.getSession(true);

      ArrayList subdomain = new ArrayList();

      String query = "select * from subdomain";
      System.out.println("query " + query);
      try {
        conn.state = conn.connect.createStatement();
      } catch (SQLException ex) {
        Logger.getLogger(CountyServlet.class.getName()).log(Level.SEVERE, null, ex);
      }
      conn.rs = conn.state.executeQuery(query);
      if (subdomain != null && subdomain.size() > 0) {
        subdomain.clear();
      }

      while (conn.rs.next()) {

        SubDomainBean DB = new SubDomainBean();
        DB.setID(conn.rs.getInt(1));
        DB.setSUBDOMAIN(conn.rs.getString(2));
        DB.setDOMAINID(conn.rs.getString(3));

        subdomain.add(DB);
      }
      session.setAttribute("subdomain", subdomain);
      String nextJSP = "/Maintenance/SubDomain.jsp";

      RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
      dispatcher.forward(request, response);
      conn.connect.close();
      System.out.println("Disconnected from database");
    } catch (SQLException ex) {
      Logger.getLogger(DICServlet.class.getName()).log(Level.SEVERE, null, ex);
      System.out.println(ex.toString());
    }
  }