示例#1
0
  /**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    Statement stmt;
    ResultSet rs;
    Connection con = null;

    try {
      Class.forName("com.mysql.jdbc.Driver");
      String connectionUrl = "jdbc:mysql://localhost/myflickr?" + "user=root&password=123456";
      con = DriverManager.getConnection(connectionUrl);

      if (con != null) {
        System.out.println("connected to mysql");
      }
    } catch (SQLException e) {
      System.out.println("SQL Exception: " + e.toString());
    } catch (ClassNotFoundException cE) {
      System.out.println("Class Not Found Exception: " + cE.toString());
    }

    try {
      stmt = con.createStatement();

      System.out.println("SELECT * FROM flickrusers WHERE name='" + username + "'");
      rs = stmt.executeQuery("SELECT * FROM flickrusers WHERE name='" + username + "'");

      while (rs.next()) {

        if (rs.getObject(1).toString().equals(username)) {

          out.println("<h1>To username pou epileksate uparxei hdh</h1>");
          out.println("<a href=\"project3.html\">parakalw dokimaste kapoio allo.</a>");

          stmt.close();
          rs.close();
          return;
        }
      }
      stmt.close();
      rs.close();

      stmt = con.createStatement();

      if (!stmt.execute("INSERT INTO flickrusers VALUES('" + username + "', '" + password + "')")) {
        out.println("<h1>Your registration is completed  " + username + "</h1>");
        out.println("<a href=\"index.jsp\">go to the login menu</a>");
        registerListener.Register(username);
      } else {
        out.println("<h1>To username pou epileksate uparxei hdh</h1>");
        out.println("<a href=\"project3.html\">Register</a>");
      }
    } catch (SQLException e) {
      throw new ServletException("Servlet Could not display records.", e);
    }
  }
示例#2
0
  public String checkValidLogin(String myUserName, String myPW) {

    try {
      Class.forName(javaSQLDriverPath);
      Connection conn =
          (Connection) DriverManager.getConnection(ConnectionPath, ConnectionUser, ConnectionPW);
      Statement st = conn.createStatement();
      String query = "Select * from User";

      ResultSet rs = st.executeQuery(query);
      while (rs.next()) {
        // return rs.getString("Username");
        if (myUserName.equals(rs.getString("Username"))) {
          if (myPW.equals(rs.getString("Password"))) {
            setUserVariables(myUserName);
            return "success";
          } else {
            return "wrongPassword";
          }
        }
      }

      rs.close();
      st.close();
      conn.close();

      return "userNotFound";
    } catch (Exception e) {

      return e.getMessage();
    }
  }
  @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    // get a connection
    ConnectionPool pool = ConnectionPool.getInstance();
    Connection connection = pool.getConnection();

    String sqlStatement = request.getParameter("sqlStatement");
    String sqlResult = "";
    try {
      // create a statement
      Statement statement = connection.createStatement();

      // parse the SQL string
      sqlStatement = sqlStatement.trim();
      if (sqlStatement.length() >= 6) {
        String sqlType = sqlStatement.substring(0, 6);
        if (sqlType.equalsIgnoreCase("select")) {
          // create the HTML for the result set
          ResultSet resultSet = statement.executeQuery(sqlStatement);
          sqlResult = SQLUtil.getHtmlTable(resultSet);
          resultSet.close();
        } else {
          int i = statement.executeUpdate(sqlStatement);
          if (i == 0) {
            sqlResult = "<p>The statement executed successfully.</p>";
          } else { // an INSERT, UPDATE, or DELETE statement
            sqlResult = "<p>The statement executed successfully.<br>" + i + " row(s) affected.</p>";
          }
        }
      }
      statement.close();
      connection.close();
    } catch (SQLException e) {
      sqlResult = "<p>Error executing the SQL statement: <br>" + e.getMessage() + "</p>";
    } finally {
      pool.freeConnection(connection);
    }

    HttpSession session = request.getSession();
    session.setAttribute("sqlResult", sqlResult);
    session.setAttribute("sqlStatement", sqlStatement);

    String url = "/index.jsp";
    getServletContext().getRequestDispatcher(url).forward(request, response);
  }
示例#4
0
 public void doPost(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   Statement question;
   String query;
   ResultSet answer;
   connect();
   try {
     query = "SELECT * FROM PILOT WHERE Address ='" + request.getParameter("city") + "'";
     question = link.createStatement();
     answer = question.executeQuery(query);
     PrintWriter pen;
     response.setContentType("text/html");
     pen = response.getWriter();
     pen.println("<HTML>");
     pen.println("<HEAD> <TITLE> Answer </TITLE> </HEAD>");
     pen.println("<BODY>");
     while (answer.next()) {
       String pN = answer.getString("PilotNumber");
       String lN = answer.getString("LastName");
       String fN = answer.getString("FirstName");
       String ad = answer.getString("Address");
       float sa = answer.getFloat("Salary");
       float pr = answer.getFloat("Premium");
       Date hD = answer.getDate("HiringDate");
       if (answer.wasNull() == false) {
         pen.println("<P><B> Pilot : </B>" + lN + " " + fN);
         pen.println("<P><B> ---Reference : </B>" + pN);
         pen.println("<P><B> ---Address : </B>" + ad);
         pen.println("<P><B> ---Salary : </B>" + sa);
         pen.println("<P><B> ---since : </B>" + hD);
         if (pr > 0) pen.println("<P><B> ---Premium : </B>" + pr);
         else pen.println("<P><B> ---No premium </B>");
       }
     }
     pen.println("</BODY>");
     pen.println("</HTML>");
     answer.close();
     question.close();
     link.close();
   } catch (SQLException e) {
     System.out.println("Connection error: " + e.getMessage());
   }
 }
示例#5
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    String dbUser = "******"; // enter your username here
    String dbPassword = "******"; // enter your password here

    try {
      OracleDataSource ods = new oracle.jdbc.pool.OracleDataSource();
      ods.setURL("jdbc:oracle:thin:@//w4111b.cs.columbia.edu:1521/ADB");
      ods.setUser(dbUser);
      ods.setPassword(dbPassword);

      Connection conn = ods.getConnection();

      String query = new String();
      Statement s = conn.createStatement();

      query = "select * from events";

      ResultSet r = s.executeQuery(query);
      while (r.next()) {
        out.println("Today's Date: " + r.getString(1) + " ");
      }
      r.close();
      s.close();

      conn.close();

    } catch (Exception e) {
      out.println("The database could not be accessed.<br>");
      out.println("More information is available as follows:<br>");
      e.printStackTrace(out);
    }
  } // end doGet method
示例#6
0
文件: Set1.java 项目: wangz/MYOA
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    request.setCharacterEncoding("gb2312");
    response.setContentType("text/html; charset=gb2312");
    out = response.getWriter();
    session = request.getSession();
    time = new Time();
    str = new Str();
    db = new Db();

    // 取得
    try {
      id = Integer.parseInt((String) request.getParameter("id"));
    } catch (Exception e) {
      id = 0;
    }
    password = request.getParameter("password");
    password = str.inStr(password);
    sqlsp = "SELECT * FROM password WHERE employeeid=" + id;
    sqlse = "SELECT employeeid FROM eminfo WHERE employeeid=" + id;
    sqlu =
        "UPDATE password SET time='"
            + time.getYMDHMS()
            + "',password='******' WHERE employeeid="
            + id;
    sqli =
        "INSERT INTO password(employeeid,password,time) VALUES("
            + id
            + ",'"
            + password
            + "','"
            + time.getYMDHMS()
            + "')";
    try {
      stmt = db.getStmtread();
      rs = stmt.executeQuery(sqlsp);
      // 不是第一次设置更新数据库
      if (rs.next()) {
        db.close();
        stmt = db.getStmt();
        temp = 0;
        temp = stmt.executeUpdate(sqlu);
        if (temp > 0) {
          request.setAttribute("msg", "设置成功");
        } else {
          request.setAttribute("msg", "设置失败");
        }
        db.close();
      } else {
        // 第一次设置
        db.close();
        temp = 0;
        stmt = db.getStmtread();
        rs = stmt.executeQuery(sqlse);
        if (rs.next()) {
          // id存在
          rs.close();
          stmt.close();
          temp = 0;
          stmt = db.getStmt();
          temp = stmt.executeUpdate(sqli);
          if (temp > 0) {
            request.setAttribute("msg", "设置成功");
          } else {
            request.setAttribute("msg", "设置失败");
          }
          db.close();
        } else {
          // id不存在
          db.close();
          request.setAttribute("msg", "员工序号不存在");
        }
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      RequestDispatcher dispatcher = request.getRequestDispatcher("set1.jsp");
      dispatcher.forward(request, response);
    }
  }
  /** Business logic to execute. */
  public VOListResponse loadItemVariants(GridParams pars, String serverLanguageId, String username)
      throws Throwable {

    PreparedStatement pstmt = null;

    Connection conn = null;
    try {
      if (this.conn == null) conn = getConn();
      else conn = this.conn;

      String tableName = (String) pars.getOtherGridParams().get(ApplicationConsts.TABLE_NAME);
      ItemPK pk = (ItemPK) pars.getOtherGridParams().get(ApplicationConsts.ITEM_PK);
      String productVariant = (String) productVariants.get(tableName);
      String variantType = (String) variantTypes.get(tableName);
      String variantTypeJoin = (String) variantTypeJoins.get(tableName);
      String variantCodeJoin = (String) variantCodeJoins.get(tableName);

      String sql =
          "select "
              + tableName
              + "."
              + variantTypeJoin
              + ","
              + tableName
              + ".VARIANT_CODE,A.DESCRIPTION,B.DESCRIPTION, "
              + tableName
              + ".PROGRESSIVE_SYS10,"
              + variantType
              + ".PROGRESSIVE_SYS10 "
              + "from "
              + tableName
              + ","
              + variantType
              + ",SYS10_COMPANY_TRANSLATIONS A,SYS10_COMPANY_TRANSLATIONS B "
              + "where "
              + tableName
              + ".COMPANY_CODE_SYS01=? and "
              + tableName
              + ".COMPANY_CODE_SYS01="
              + variantType
              + ".COMPANY_CODE_SYS01 and "
              + tableName
              + "."
              + variantTypeJoin
              + "="
              + variantType
              + ".VARIANT_TYPE and "
              + tableName
              + ".COMPANY_CODE_SYS01=A.COMPANY_CODE_SYS01 and "
              + tableName
              + ".PROGRESSIVE_SYS10=A.PROGRESSIVE and A.LANGUAGE_CODE=? and "
              + variantType
              + ".COMPANY_CODE_SYS01=B.COMPANY_CODE_SYS01 and "
              + variantType
              + ".PROGRESSIVE_SYS10=B.PROGRESSIVE and B.LANGUAGE_CODE=? and "
              + tableName
              + ".ENABLED='Y' and "
              + variantType
              + ".ENABLED='Y' and "
              + // and not "+tableName+"."+variantTypeJoin+"=? and "+
              "not "
              + tableName
              + ".VARIANT_CODE=? "
              + "order by "
              + tableName
              + "."
              + variantTypeJoin
              + ","
              + tableName
              + ".CODE_ORDER";

      Map attribute2dbField = new HashMap();
      attribute2dbField.put("variantType", tableName + "." + variantTypeJoin);
      attribute2dbField.put("variantCode", tableName + ".VARIANT_CODE");
      attribute2dbField.put("variantDesc", "A.DESCRIPTION");
      attribute2dbField.put("variantTypeDesc", "B.DESCRIPTION");
      attribute2dbField.put("variantProgressiveSys10", tableName + ".PROGRESSIVE_SYS10");
      attribute2dbField.put("variantTypeProgressiveSys10", variantType + ".PROGRESSIVE_SYS10");

      ArrayList values = new ArrayList();
      values.add(pk.getCompanyCodeSys01ITM01());
      values.add(serverLanguageId);
      values.add(serverLanguageId);
      // values.add(ApplicationConsts.JOLLY);
      values.add(ApplicationConsts.JOLLY);

      // read from ITMxxx table...
      Response answer =
          QueryUtil.getQuery(
              conn,
              new UserSessionParameters(username),
              sql,
              values,
              attribute2dbField,
              ItemVariantVO.class,
              "Y",
              "N",
              null,
              pars,
              50,
              true);

      if (!answer.isError()) {
        java.util.List vos = ((VOListResponse) answer).getRows();
        HashMap map = new HashMap();
        ItemVariantVO vo = null;
        for (int i = 0; i < vos.size(); i++) {
          vo = (ItemVariantVO) vos.get(i);
          vo.setCompanyCodeSys01(pk.getCompanyCodeSys01ITM01());
          vo.setItemCodeItm01(pk.getItemCodeITM01());
          vo.setTableName(tableName);
          map.put(vo.getVariantType() + "." + vo.getVariantCode(), vo);
        }

        pstmt =
            conn.prepareStatement(
                "select "
                    + productVariant
                    + "."
                    + variantTypeJoin
                    + ","
                    + productVariant
                    + "."
                    + variantCodeJoin
                    + " "
                    + "from "
                    + productVariant
                    + " "
                    + "where "
                    + productVariant
                    + ".COMPANY_CODE_SYS01=? and "
                    + productVariant
                    + ".ITEM_CODE_ITM01=? and "
                    + productVariant
                    + ".ENABLED='Y' ");
        pstmt.setString(1, pk.getCompanyCodeSys01ITM01());
        pstmt.setString(2, pk.getItemCodeITM01());
        ResultSet rset = pstmt.executeQuery();

        while (rset.next()) {
          vo = (ItemVariantVO) map.get(rset.getString(1) + "." + rset.getString(2));
          if (vo != null) vo.setSelected(Boolean.TRUE);
        }
        rset.close();
        pstmt.close();
      }

      if (answer.isError()) throw new Exception(answer.getErrorMessage());
      else return (VOListResponse) answer;

    } catch (Throwable ex) {
      Logger.error(
          username,
          this.getClass().getName(),
          "getItemVariants",
          "Error while fetching item variants list",
          ex);
      throw new Exception(ex.getMessage());
    } finally {
      try {
        pstmt.close();
      } catch (Exception ex2) {
      }
      try {
        if (this.conn == null && conn != null) {
          // close only local connection
          conn.commit();
          conn.close();
        }

      } catch (Exception exx) {
      }
    }
  }
  /** Business logic to execute. */
  public final Response executeCommand(
      Object inputPar,
      UserSessionParameters userSessionPars,
      HttpServletRequest request,
      HttpServletResponse response,
      HttpSession userSession,
      ServletContext context) {
    String serverLanguageId = ((JAIOUserSessionParameters) userSessionPars).getServerLanguageId();

    Connection conn = null;
    PreparedStatement pstmt = null;
    try {
      conn = ConnectionManager.getConnection(context);

      // fires the GenericEvent.CONNECTION_CREATED event...
      EventsManager.getInstance()
          .processEvent(
              new GenericEvent(
                  this,
                  getRequestName(),
                  GenericEvent.CONNECTION_CREATED,
                  (JAIOUserSessionParameters) userSessionPars,
                  request,
                  response,
                  userSession,
                  context,
                  conn,
                  inputPar,
                  null));

      // retrieve companies list...
      GridParams gridParams = (GridParams) inputPar;
      String companies =
          (String)
              gridParams
                  .getOtherGridParams()
                  .get(ApplicationConsts.COMPANY_CODE_SYS01); // used in lookup grid...
      if (companies == null) {
        ArrayList companiesList =
            ((JAIOUserSessionParameters) userSessionPars).getCompanyBa().getCompaniesList("SAL06");
        companies = "";
        for (int i = 0; i < companiesList.size(); i++)
          companies += "'" + companiesList.get(i).toString() + "',";
        companies = companies.substring(0, companies.length() - 1);
      } else companies = "'" + companies + "'";

      String sql =
          "select SAL06_CHARGES.COMPANY_CODE_SYS01,SAL06_CHARGES.CHARGE_CODE,SAL06_CHARGES.PROGRESSIVE_SYS10,"
              + "SYS10_TRANSLATIONS.DESCRIPTION,SAL06_CHARGES.VALUE,SAL06_CHARGES.PERC,SAL06_CHARGES.VAT_CODE_REG01,"
              + "SAL06_CHARGES.CURRENCY_CODE_REG03,SAL06_CHARGES.ENABLED"
              + " from SAL06_CHARGES,SYS10_TRANSLATIONS where "
              + "SAL06_CHARGES.PROGRESSIVE_SYS10=SYS10_TRANSLATIONS.PROGRESSIVE and "
              + "SYS10_TRANSLATIONS.LANGUAGE_CODE=? and "
              + "SAL06_CHARGES.ENABLED='Y' and "
              + "SAL06_CHARGES.COMPANY_CODE_SYS01 in ("
              + companies
              + ")";

      Map attribute2dbField = new HashMap();
      attribute2dbField.put("companyCodeSys01SAL06", "SAL06_CHARGES.COMPANY_CODE_SYS01");
      attribute2dbField.put("chargeCodeSAL06", "SAL06_CHARGES.CHARGE_CODE");
      attribute2dbField.put("descriptionSYS10", "SYS10_TRANSLATIONS.DESCRIPTION");
      attribute2dbField.put("progressiveSys10SAL06", "SAL06_CHARGES.PROGRESSIVE_SYS10");
      attribute2dbField.put("valueSAL06", "SAL06_CHARGES.VALUE");
      attribute2dbField.put("percSAL06", "SAL06_CHARGES.PERC");
      attribute2dbField.put("vatCodeReg01SAL06", "SAL06_CHARGES.VAT_CODE_REG01");
      attribute2dbField.put("currencyCodeReg03SAL06", "SAL06_CHARGES.CURRENCY_CODE_REG03");
      attribute2dbField.put("enabledSAL06", "SAL06_CHARGES.ENABLED");

      ArrayList values = new ArrayList();
      values.add(serverLanguageId);

      // read from SAL06 table...
      Response res =
          CustomizeQueryUtil.getQuery(
              conn,
              userSessionPars,
              sql,
              values,
              attribute2dbField,
              ChargeVO.class,
              "Y",
              "N",
              context,
              gridParams,
              50,
              true,
              new BigDecimal(292) // window identifier...
              );
      if (res.isError()) return res;

      ArrayList list = ((VOListResponse) res).getRows();
      ChargeVO vo = null;
      sql =
          "select SYS10_TRANSLATIONS.DESCRIPTION,REG01_VATS.VALUE,REG01_VATS.DEDUCTIBLE "
              + "from SYS10_TRANSLATIONS,REG01_VATS where "
              + "REG01_VATS.PROGRESSIVE_SYS10=SYS10_TRANSLATIONS.PROGRESSIVE and "
              + "SYS10_TRANSLATIONS.LANGUAGE_CODE=? and "
              + "REG01_VATS.VAT_CODE=?";
      pstmt = conn.prepareStatement(sql);
      ResultSet rset = null;
      for (int i = 0; i < list.size(); i++) {
        vo = (ChargeVO) list.get(i);
        if (vo.getVatCodeReg01SAL06() != null) {
          // retrieve vat data from REG01...
          pstmt.setString(1, serverLanguageId);
          pstmt.setString(2, vo.getVatCodeReg01SAL06());
          rset = pstmt.executeQuery();
          if (rset.next()) {
            vo.setVatDescriptionSYS10(rset.getString(1));
            vo.setVatValueREG01(rset.getBigDecimal(2));
            vo.setVatDeductibleREG01(rset.getBigDecimal(3));
          }
          rset.close();
        }
      }

      Response answer = res;

      // fires the GenericEvent.BEFORE_COMMIT event...
      EventsManager.getInstance()
          .processEvent(
              new GenericEvent(
                  this,
                  getRequestName(),
                  GenericEvent.BEFORE_COMMIT,
                  (JAIOUserSessionParameters) userSessionPars,
                  request,
                  response,
                  userSession,
                  context,
                  conn,
                  inputPar,
                  answer));

      return answer;
    } catch (Throwable ex) {
      Logger.error(
          userSessionPars.getUsername(),
          this.getClass().getName(),
          "executeCommand",
          "Error while fetching charges list",
          ex);
      return new ErrorResponse(ex.getMessage());
    } finally {
      try {
        pstmt.close();
      } catch (Exception ex2) {
      }
      try {
        ConnectionManager.releaseConnection(conn, context);
      } catch (Exception ex1) {
      }
    }
  }
示例#9
0
  /**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    Statement stmt;
    ResultSet rs;

    if (username == null || password == null) {
      out.println("<h1>Invalid Register Request</h1>");
      out.println("<a href=\"register.html\">Register</a>");

      return;
    }
    Connection con = null;

    try {
      Class.forName("com.mysql.jdbc.Driver");
      String connectionUrl = "jdbc:mysql://localhost/project3?" + "user=root&password=marouli";
      con = DriverManager.getConnection(connectionUrl);

      if (con != null) {
        System.out.println("Ola ok me mysql");
      }
    } catch (SQLException e) {
      System.out.println("SQL Exception: " + e.toString());
    } catch (ClassNotFoundException cE) {
      System.out.println("Class Not Found Exception: " + cE.toString());
    }

    try {
      stmt = con.createStatement();

      rs = stmt.executeQuery("SELECT * FROM users WHERE username='******'");
      if (rs.next()) {
        out.println("<h1>Username exists</h1>");
        out.println("<a href=\"register.html\">Register</a>");

        stmt.close();
        rs.close();
        con.close();
        return;
      }
      stmt.close();
      rs.close();

      stmt = con.createStatement();

      if (!stmt.execute("INSERT INTO users VALUES('" + username + "', '" + password + "')")) {
        out.println("<h1>You are now registered " + username + "</h1>");
        out.println("<a href=\"index.jsp\">Login</a>");

        int i;
        for (i = 0; i < listeners.size(); i++) listeners.get(i).UserRegistered(username);
      } else {
        out.println("<h1>Could not add your username to the db</h1>");
        out.println("<a href=\"register.html\">Register</a>");
      }

      stmt.close();
      con.close();
    } catch (SQLException e) {
      throw new ServletException("Servlet Could not display records.", e);
    }
  }
示例#10
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html;charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;
      _jspx_resourceInjector =
          (org.apache.jasper.runtime.ResourceInjector)
              application.getAttribute("com.sun.appserv.jsp.resource.injector");

      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write(" ");

      DataSource ds = null;
      Connection con = null;
      PreparedStatement ps = null;
      InitialContext ic;
      try {
        ic = new InitialContext();
        ds = (DataSource) ic.lookup("java:/jdbc/AVMS");
        // ds = (DataSource)ic.lookup( "java:/jboss" );
        con = ds.getConnection();
        ps = con.prepareStatement("SELECT * FROM dbo.ROLE");
        // pr = con.prepareStatement("SELECT * FROM dbo.JMS_USERS");
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
          out.println("<br> " + rs.getString("role_name") + " | " + rs.getString("role_desc"));
          // out.println("<br> " +rs.getString("USERID") + " | " +rs.getString("PASSWD"));
        }
        rs.close();
        ps.close();
      } catch (Exception e) {
        out.println("Exception thrown :: " + e);
      } finally {
        if (con != null) {
          con.close();
        }
      }
      out.write('\n');
      out.write('\n');
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
  /** Business logic to execute. */
  public final Response executeCommand(
      Object inputPar,
      UserSessionParameters userSessionPars,
      HttpServletRequest request,
      HttpServletResponse response,
      HttpSession userSession,
      ServletContext context) {
    Connection conn = null;
    PreparedStatement pstmt = null;
    try {
      String serverLanguageId = ((JAIOUserSessionParameters) userSessionPars).getServerLanguageId();
      conn = ConnectionManager.getConnection(context);

      // fires the GenericEvent.CONNECTION_CREATED event...
      EventsManager.getInstance()
          .processEvent(
              new GenericEvent(
                  this,
                  getRequestName(),
                  GenericEvent.CONNECTION_CREATED,
                  (JAIOUserSessionParameters) userSessionPars,
                  request,
                  response,
                  userSession,
                  context,
                  conn,
                  inputPar,
                  null));

      ArrayList oldVOs = ((ArrayList[]) inputPar)[0];
      ArrayList newVOs = ((ArrayList[]) inputPar)[1];

      Map attribute2dbField = new HashMap();
      attribute2dbField.put("companyCodeSys01DOC20", "COMPANY_CODE_SYS01");
      attribute2dbField.put("progressiveDoc14DOC20", "PROGRESSIVE_DOC14");
      attribute2dbField.put("progressiveSys10DOC20", "PROGRESSIVE_SYS10");
      attribute2dbField.put("textValueDOC20", "TEXT_VALUE");
      attribute2dbField.put("numValueDOC20", "NUM_VALUE");
      attribute2dbField.put("dateValueDOC20", "DATE_VALUE");

      HashSet pkAttributes = new HashSet();
      pkAttributes.add("companyCodeSys01DOC20");
      pkAttributes.add("progressiveDoc14DOC20");
      pkAttributes.add("progressiveSys10DOC20");

      Response res = null;
      DocPropertyVO oldVO = null;
      DocPropertyVO newVO = null;

      pstmt =
          conn.prepareStatement(
              "select PROGRESSIVE_DOC14 from DOC20_DOC_PROPERTIES where "
                  + "COMPANY_CODE_SYS01=? and PROGRESSIVE_DOC14=? and PROGRESSIVE_SYS10=?");
      ResultSet rset = null;

      for (int i = 0; i < oldVOs.size(); i++) {
        oldVO = (DocPropertyVO) oldVOs.get(i);
        newVO = (DocPropertyVO) newVOs.get(i);

        // check if the record already exists: if it does not exist, then insert it...
        pstmt.setString(1, newVO.getCompanyCodeSys01DOC20());
        pstmt.setBigDecimal(2, newVO.getProgressiveDoc14DOC20());
        pstmt.setBigDecimal(3, newVO.getProgressiveSys10DOC20());
        rset = pstmt.executeQuery();
        if (rset.next()) {
          // the record exixts: it will be updated...
          res =
              QueryUtil.updateTable(
                  conn,
                  userSessionPars,
                  pkAttributes,
                  oldVO,
                  newVO,
                  "DOC20_DOC_PROPERTIES",
                  attribute2dbField,
                  "Y",
                  "N",
                  context,
                  true);
          if (res.isError()) {
            conn.rollback();
            return res;
          }
        } else {
          // the record does not exixt: it will be inserted...
          res =
              QueryUtil.insertTable(
                  conn,
                  userSessionPars,
                  newVO,
                  "DOC20_DOC_PROPERTIES",
                  attribute2dbField,
                  "Y",
                  "N",
                  context,
                  true);
          if (res.isError()) {
            conn.rollback();
            return res;
          }
        }
        rset.close();
      }

      Response answer = new VOListResponse(newVOs, false, newVOs.size());

      // fires the GenericEvent.BEFORE_COMMIT event...
      EventsManager.getInstance()
          .processEvent(
              new GenericEvent(
                  this,
                  getRequestName(),
                  GenericEvent.BEFORE_COMMIT,
                  (JAIOUserSessionParameters) userSessionPars,
                  request,
                  response,
                  userSession,
                  context,
                  conn,
                  inputPar,
                  answer));

      conn.commit();

      // fires the GenericEvent.AFTER_COMMIT event...
      EventsManager.getInstance()
          .processEvent(
              new GenericEvent(
                  this,
                  getRequestName(),
                  GenericEvent.AFTER_COMMIT,
                  (JAIOUserSessionParameters) userSessionPars,
                  request,
                  response,
                  userSession,
                  context,
                  conn,
                  inputPar,
                  answer));

      return answer;
    } catch (Throwable ex) {
      Logger.error(
          userSessionPars.getUsername(),
          this.getClass().getName(),
          "executeCommand",
          "Error while updating property values for the specified document",
          ex);
      try {
        conn.rollback();
      } catch (Exception ex3) {
      }
      return new ErrorResponse(ex.getMessage());
    } finally {
      try {
        pstmt.close();
      } catch (Exception ex2) {
      }
      try {
        ConnectionManager.releaseConnection(conn, context);
      } catch (Exception ex1) {
      }
    }
  }
示例#12
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write('\n');
      out.write('\n');

      Connection conn = null;
      Class.forName("com.mysql.jdbc.Driver");
      conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/db_shas", "root", "password");

      ResultSet rsdoLogin = null;
      PreparedStatement psdoLogin = null;

      String sUserID = request.getParameter("username");
      String sPassword = request.getParameter("password");
      String message = "User login successfully ";

      try {
        String sqlOption =
            "select * FROM Users where username='******' and Password='******'";
        psdoLogin = conn.prepareStatement(sqlOption);
        //     psdoLogin.setString(1,sUserID);
        //     psdoLogin.setString(2,sPassword);

        rsdoLogin = psdoLogin.executeQuery();

        if (rsdoLogin.next()) {
          String sUserName =
              rsdoLogin.getString("firstname") + " " + rsdoLogin.getString("lastname");
          session.setAttribute("sUserID", sUserName);
          // session.setAttribute("sUserID",rsdoLogin.getString("firstname"));
          //       session.setAttribute("iUserType",rsdoLogin.getString("iUserType"));
          //       session.setAttribute("iUserLevel",rsdoLogin.getString("iUserLevel"));
          //       session.setAttribute("sUserName",sUserName);

          response.sendRedirect("success.jsp?statusmsg=" + message);
        } else {
          message = "Invalid credentials";
          response.sendRedirect("Invalid.jsp?error=" + message);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }

      /// close object and connection
      try {
        if (psdoLogin != null) {
          psdoLogin.close();
        }
        if (rsdoLogin != null) {
          rsdoLogin.close();
        }

        if (conn != null) {
          conn.close();
        }
      } catch (Exception e) {
        e.printStackTrace();
      }

    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try {
            out.clearBuffer();
          } catch (java.io.IOException e) {
          }
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    HttpSession session = request.getSession(true);

    try {
      Object accountObject = session.getValue(ACCOUNT);

      // If no account object was put in the session, or
      // if one exists but it is not a hashtable, then
      // redirect the user to the original login page

      if (accountObject == null)
        throw new RuntimeException("You need to log in to use this service!");

      if (!(accountObject instanceof Hashtable))
        throw new RuntimeException("You need to log in to use this service!");

      Hashtable account = (Hashtable) accountObject;

      String userName = (String) account.get("name");

      //////////////////////////////////////////////
      // Display Messages for the user who logged in
      //////////////////////////////////////////////

      Connection con = null;
      Statement stmt = null;
      ResultSet rs = null;

      String lookupID = request.getParameter("LookupMemberID");

      out.println("<HTML>");
      out.println("<HEAD>");
      out.println("<TITLE>Searching for member: lookupID</TITLE>");
      out.println("</HEAD>");
      out.println("<BODY BGCOLOR='#EFEFEF'>");
      out.println("<H3><u>Searching for Member ID: " + lookupID + "</u></H3>");
      out.println("<CENTER>");

      try {
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        con =
            DriverManager.getConnection(
                "jdbc:mysql://localhost/contacts?user=kareena&password=kapoor");

        stmt = con.createStatement();
        rs =
            stmt.executeQuery(
                "SELECT * FROM userstable WHERE UserID=" + Integer.parseInt(lookupID));

        out.println("<TABLE BGCOLOR='#EFEFFF' CELLPADDING='2' CELLSPACING='4' BORDER='1'>");
        out.println("<TR BGCOLOR='#D6DFFF'>");
        out.println("<TD ALIGN='center'><B>Picture</B></TD>");
        out.println("<TD ALIGN='center'><B>User Name</B></TD>");
        out.println("<TD ALIGN='center'><B>Gender</B></TD>");
        out.println("<TD ALIGN='center'><B>City / State</B></TD>");
        out.println("<TD ALIGN='center'><B>Country</B></TD>");
        out.println("<TD ALIGN='center'><B>About User</B></TD>");
        out.println("<TD ALIGN='center'><B>User Profile</B></TD>");
        out.println("<TD ALIGN='center'><B>Add to Contact List</B></TD>");
        out.println("</TR>");

        int i = 0;
        String formName = "form";
        String buttonName = "button";

        while (rs.next()) {
          String picture = rs.getString("FileLocation");
          String user = rs.getString("UserName");
          String city = rs.getString("City");
          String state = rs.getString("State");
          String country = rs.getString("Country");
          String aboutUser = rs.getString("AboutMe1");
          String gender = rs.getString("Gender");

          formName += i;
          buttonName += i;

          out.println("<form name='" + formName + "' method='post' action='addContact'>");
          out.println("<TR>");
          out.println("<TD><img src='" + picture + "'</TD>");
          out.println("<TD>" + user + "</TD>");
          out.println("<TD>" + gender + "</TD>");
          out.println("<TD>" + city + " / " + state + "</TD>");
          out.println("<TD>" + country + "</TD>");

          out.println("<TD>" + aboutUser + "</TD>");
          out.println(
              "<TD><A href='details.jsp?type=1&data="
                  + lookupID
                  + "'><IMG SRC='images/detail.jpg'></A></TD>");
          out.println(
              "<TD><input type='submit' value='Add to Contact List' name='"
                  + buttonName
                  + "'></TD>");
          out.println("<input type='hidden' value='" + user + "' name='hiddenUser'>");
          out.println("</TR>");
          out.println("</form>");

          i++;
        }
        out.println("</TABLE>");
      } catch (Exception e) {
        out.println("Could not connect to the users database.<P>");
        out.println("The error message was");
        out.println("<PRE>");
        out.println(e.getMessage());
        out.println("</PRE>");
      } finally {
        if (rs != null) {
          try {
            rs.close();
          } catch (SQLException ignore) {
          }
        }
        if (stmt != null) {
          try {
            stmt.close();
          } catch (SQLException ignore) {
          }
        }
        if (con != null) {
          try {
            con.close();
          } catch (SQLException ignore) {
          }
        }
      }

      out.println("</CENTER>");
      out.println("</BODY>");
      out.println("</HTML>");

    } catch (RuntimeException e) {
      out.println("<script language=\"javascript\">");
      out.println("alert(\"You need to log in to use this service!\");");
      out.println("</script>");

      out.println("<a href='index.html'>Click Here</a> to go to the main page.<br><br>");

      out.println(
          "Or Click on the button to exit<FORM><INPUT onClick=\"javascipt:window.close()\" TYPE=\"BUTTON\" VALUE=\"Close Browser\" TITLE=\"Click here to close window\" NAME=\"CloseWindow\" STYLE=\"font-family:Verdana, Arial, Helvetica; font-size:smaller; font-weight:bold\"></FORM>");

      log(e.getMessage());
      return;
    }
  }
示例#14
0
文件: Signup.java 项目: kotseas/PPC
 @Override
 public void doPost(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   out = response.getWriter();
   HttpSession session;
   String connectionURL = USERS_INFO;
   Connection connection = null;
   ResultSet rs;
   String email = "";
   String userName = "";
   String passwrd = "";
   String remoteAddr = "";
   response.setContentType("text/html");
   int error = 0;
   try {
     // Load the database driver
     Class.forName("com.mysql.jdbc.Driver");
     // Get a Connection to the database
     connection = DriverManager.getConnection(connectionURL, USERNAME, PASSWORD);
     // Add the data into the database
     String sql = "SELECT username, email FROM users";
     Statement s = connection.createStatement();
     s.executeQuery(sql);
     rs = s.getResultSet();
     while (rs.next()) {
       email = rs.getString("email");
       userName = rs.getString("username");
       if (email.equals(request.getParameter("email"))) {
         String message = "Email" + email + "already exists";
         request.setAttribute("RegisterMessage", message);
         RequestDispatcher view = request.getRequestDispatcher("signup.jsp");
         view.forward(request, response);
         error = 1;
       }
       if (userName.equals(request.getParameter("user"))) {
         String message = "Username '" + userName + "' already exists";
         request.setAttribute("RegisterMessage", message);
         RequestDispatcher view = request.getRequestDispatcher("signup.jsp");
         view.forward(request, response);
         error = 1;
       }
       if (error == 1) {
         break;
       }
     }
     passwrd = request.getParameter("pass");
     if (!passwrd.equalsIgnoreCase(request.getParameter("pass2"))) {
       String message = "Passwords don't match";
       request.setAttribute("RegisterMessage", message);
       RequestDispatcher view = request.getRequestDispatcher("signup.jsp");
       view.forward(request, response);
       error = 1;
     }
     remoteAddr = request.getRemoteAddr();
     // ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
     // reCaptcha.setPrivateKey("6LezstoSAAAAAEE9lfB6TR2kEX81_peDt4n03K4l");
     // String challenge = request.getParameter("recaptcha_challenge_field");
     // String uresponse = request.getParameter("recaptcha_response_field");
     // ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(remoteAddr, challenge,
     // uresponse);
     /*if (!reCaptchaResponse.isValid()) {
     print_wrong_once(error);
     out.print("<h2 align=\"center\">Validation code is wrong.</h2>");
     error = 1;
     }*/
     if (error == 1) {
       rs.close();
       s.close();
       return;
     } else {
       sql =
           "INSERT INTO users_info.users (`username`, `password`, `email`) VALUES ('"
               + request.getParameter("user")
               + "', '"
               + request.getParameter("pass")
               + "', '"
               + request.getParameter("email")
               + "')";
       s.executeUpdate(sql);
       File dir = new File(mainPath + "/" + request.getParameter("user"));
       dir.mkdir();
       session = request.getSession(true);
       session.setAttribute("username", request.getParameter("user"));
       response.sendRedirect(response.encodeRedirectURL("XmlParser"));
     }
     rs.close();
     s.close();
     connection.close();
   } catch (Exception e) {
     System.out.println("Unexpected error: " + e);
   }
 }
  /** Business logic to execute. */
  public final Response executeCommand(
      Object inputPar,
      UserSessionParameters userSessionPars,
      HttpServletRequest request,
      HttpServletResponse response,
      HttpSession userSession,
      ServletContext context) {
    String serverLanguageId = ((JAIOUserSessionParameters) userSessionPars).getServerLanguageId();
    Connection conn = null;
    Statement stmt = null;
    try {
      conn = ConnectionManager.getConnection(context);

      // fires the GenericEvent.CONNECTION_CREATED event...
      EventsManager.getInstance()
          .processEvent(
              new GenericEvent(
                  this,
                  getRequestName(),
                  GenericEvent.CONNECTION_CREATED,
                  (JAIOUserSessionParameters) userSessionPars,
                  request,
                  response,
                  userSession,
                  context,
                  conn,
                  inputPar,
                  null));
      java.util.List list = (ArrayList) inputPar;

      HierarItemDiscountVO vo = null;
      ResultSet rset = null;
      stmt = conn.createStatement();
      for (int i = 0; i < list.size(); i++) {
        vo = (HierarItemDiscountVO) list.get(i);
        vo.setDiscountTypeSAL03(ApplicationConsts.DISCOUNT_CUSTOMER);

        // retrieve COMPANY_CODE from progressiveHIE01...
        rset =
            stmt.executeQuery(
                "select COMPANY_CODE_SYS01 from ITM02_ITEM_TYPES where PROGRESSIVE_HIE02 in "
                    + "(select PROGRESSIVE_HIE02 from HIE01_LEVELS where PROGRESSIVE="
                    + vo.getProgressiveHie01SAL05()
                    + ")");
        if (rset.next()) vo.setCompanyCodeSys01SAL03(rset.getString(1));
        else {
          rset.close();
          conn.rollback();
          return new ErrorResponse("Item hierarchy not found.");
        }
        rset.close();

        DiscountBean.insertDiscount(conn, vo);

        stmt.execute(
            "insert into SAL05_ITEM_HIERAR_DISCOUNTS(COMPANY_CODE_SYS01,PROGRESSIVE_HIE01,DISCOUNT_CODE_SAL03) "
                + "values('"
                + vo.getCompanyCodeSys01SAL03()
                + "',"
                + vo.getProgressiveHie01SAL05()
                + ",'"
                + vo.getDiscountCodeSAL03()
                + "')");
      }

      Response answer = new VOListResponse(list, false, list.size());

      // fires the GenericEvent.BEFORE_COMMIT event...
      EventsManager.getInstance()
          .processEvent(
              new GenericEvent(
                  this,
                  getRequestName(),
                  GenericEvent.BEFORE_COMMIT,
                  (JAIOUserSessionParameters) userSessionPars,
                  request,
                  response,
                  userSession,
                  context,
                  conn,
                  inputPar,
                  answer));

      conn.commit();

      // fires the GenericEvent.AFTER_COMMIT event...
      EventsManager.getInstance()
          .processEvent(
              new GenericEvent(
                  this,
                  getRequestName(),
                  GenericEvent.AFTER_COMMIT,
                  (JAIOUserSessionParameters) userSessionPars,
                  request,
                  response,
                  userSession,
                  context,
                  conn,
                  inputPar,
                  answer));

      return answer;
    } catch (Throwable ex) {
      Logger.error(
          userSessionPars.getUsername(),
          this.getClass().getName(),
          "executeCommand",
          "Error while inserting hierarchy item discounts",
          ex);
      try {
        conn.rollback();
      } catch (Exception ex3) {
      }
      return new ErrorResponse(ex.getMessage());
    } finally {
      try {
        stmt.close();
      } catch (Exception ex2) {
      }
      try {
        ConnectionManager.releaseConnection(conn, context);
      } catch (Exception ex1) {
      }
    }
  }
示例#16
0
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    resp.setContentType("text/html");
    PrintWriter out = resp.getWriter();

    PreparedStatement pstmt = null;
    Statement stmt = null;
    ResultSet rs = null;

    HttpSession session = SystemUtils.verifyMem(req, out); // check for intruder

    if (session == null) return;

    Connection con = Connect.getCon(req); // get DB connection

    if (con == null) {

      resp.setContentType("text/html");

      out.println(SystemUtils.HeadTitle("DB Connection Error"));
      out.println("<BODY><CENTER><BR>");
      out.println("<BR><BR><H3>Database Connection Error</H3>");
      out.println("<BR><BR>Unable to connect to the Database.");
      out.println("<BR>Please try again later.");
      out.println("<BR><BR>If problem persists, contact customer support.");
      out.println("<BR><BR>");
      out.println("<a href=\"javascript:history.back(1)\">Return</a>");
      out.println("</CENTER></BODY></HTML>");
      out.close();
      return;
    }

    //
    // Get needed vars out of session obj
    //
    String club = (String) session.getAttribute("club");
    String user = (String) session.getAttribute("user");
    String caller = (String) session.getAttribute("caller");

    int activity_id = (Integer) session.getAttribute("activity_id");

    int foretees_mode = 0;

    String stype_id = req.getParameter("type_id");
    int type_id = 0;

    String sgroup_id = req.getParameter("group_id");
    int group_id = 0;

    String sitem_id = req.getParameter("item_id");
    int item_id = 0;

    try {
      type_id = Integer.parseInt(stype_id);
    } catch (NumberFormatException ignore) {
    }

    try {
      group_id = Integer.parseInt(sgroup_id);
    } catch (NumberFormatException ignore) {
    }

    try {
      item_id = Integer.parseInt(sitem_id);
    } catch (NumberFormatException ignore) {
    }

    out.println(
        "<!-- type_id=" + type_id + ", group_id=" + group_id + ", item_id=" + item_id + " -->");

    //
    // START PAGE OUTPUT
    //
    out.println(SystemUtils.HeadTitle("Member Acivities"));
    out.println("<style>");
    out.println(".actLink { color: black }");
    out.println(".actLink:hover { color: #336633 }");
    // out.println(".playerTD {width:125px}");
    out.println("</style>");
    out.println(
        "<body bgcolor=\"#CCCCAA\" text=\"#000000\" link=\"#336633\" vlink=\"#8B8970\" alink=\"#8B8970\">");
    SystemUtils.getMemberSubMenu(req, out, caller); // required to allow submenus on this page

    //
    // DISPLAY A LIST OF AVAILABLE ACTIVITIES
    //
    out.println(
        "<p align=center><b><font size=5 color=#336633><BR><BR>Available Activities</font></b></p>");

    out.println(
        "<p align=center><b><font size=3 color=#000000>Select your desired activity from the list below.<br>NOTE: You can set your default activity under <a href=\"Member_services\" class=actLink>Settings</a>.</font></b></p>");

    out.println("<table align=center>");

    try {

      stmt = con.createStatement();

      rs = stmt.executeQuery("SELECT foretees_mode FROM club5 WHERE clubName <> '';");

      if (rs.next()) {
        foretees_mode = rs.getInt(1);
      }

      // if they have foretees then give a link in to the golf system
      if (foretees_mode != 0) {

        out.println(
            "<tr><td align=center><b><a href=\"Member_jump?switch&activity_id=0\" class=linkA style=\"color:#336633\" target=_top>Golf</a></b></td></tr>"); // ForeTees
      }

      // build a link to any activities they have access to
      rs =
          stmt.executeQuery(
              "SELECT * FROM activities " + "WHERE parent_id = 0 " + "ORDER BY activity_name");

      while (rs.next()) {

        out.println(
            "<tr><td align=center><b><a href=\"Member_jump?switch&activity_id="
                + rs.getInt("activity_id")
                + "\" class=linkA style=\"color:#336633\" target=_top>"
                + rs.getString("activity_name")
                + "</a></b></td></tr>");
      }

      stmt.close();

    } catch (Exception exc) {

      out.println("<p>ERROR:" + exc.toString() + "</p>");

    } finally {

      try {
        rs.close();
      } catch (Exception ignore) {
      }

      try {
        stmt.close();
      } catch (Exception ignore) {
      }
    }

    out.println("</table>");

    out.println("</body></html>");

    /*

        out.println("<script>");

        out.println("function load_types() {");
        out.println(" try {document.forms['frmSelect'].item_id.selectedIndex = -1; } catch (err) {}");
        out.println(" document.forms['frmSelect'].group_id.selectedIndex = -1;");
        out.println(" document.forms['frmSelect'].submit();");
        out.println("}");

        out.println("function load_groups() {");
        out.println(" document.forms['frmSelect'].submit();");
        out.println("}");

        out.println("function load_times(id) {");
        out.println(" top.bot.location.href='Member_gensheets?id=' + id;");
        out.println("}");

        out.println("</script>");

        out.println("<form name=frmSelect>");

        // LOAD ACTIVITY TYPES
        out.println("<select name=type_id onchange=\"load_types()\">");

        if (type_id == 0) {

            out.println("<option>CHOOSE TYPE</option>");

        }

        try {

            stmt = con.createStatement();

            rs = stmt.executeQuery("SELECT * FROM activities WHERE parent_id = 0");

            while (rs.next()) {

                Common_Config.buildOption(rs.getInt("activity_id"), rs.getString("activity_name"), type_id, out);

            }
            stmt.close();

        } catch (Exception exc) {

            out.println("<p>ERROR:" + exc.toString() + "</p>");

        }

        out.println("");
        out.println("</select>");


        // LOAD ACTIVITIES BY GROUP TYPE
        out.println("<select name=group_id onchange=\"load_groups()\">");

        if (type_id == 0) {

            out.println("<option>CHOOSE TYPE</option>");

        } else {

            try {

                stmt = con.createStatement();
                rs = stmt.executeQuery("SELECT activity_id, activity_name FROM activities WHERE parent_id = " + type_id);

                rs.last();
                if (rs.getRow() == 1) {
                    group_id = rs.getInt("activity_id");
                    out.println("<!-- ONLY FOUND 1 GROUP -->");
                } else {
                    out.println("<option value=\"0\">CHOOSE...</option>");
                }

                rs.beforeFirst();

                while (rs.next()) {

                    Common_Config.buildOption(rs.getInt("activity_id"), rs.getString("activity_name"), group_id, out);

                }
                stmt.close();

            } catch (Exception exc) {

                out.println("<p>ERROR:" + exc.toString() + "</p>");

            }

        }

        out.println("");
        out.println("</select>");

        boolean do_load = false;

        if (group_id > 0 ) { //|| sitem_id != null

            // LOAD ACTIVITIES BY ITEM TYPE

            try {

                stmt = con.createStatement();
                rs = stmt.executeQuery("SELECT activity_id, activity_name FROM activities WHERE parent_id = " + group_id);

                rs.last();
                if (rs.getRow() == 0) {

                    // no sub groups found
                    do_load = true;
                    item_id = group_id;

                } else if (rs.getRow() == 1) {

                    // single sub group found (pre select it)
                    item_id = rs.getInt("activity_id");
                    out.println("<!-- ONLY FOUND 1 ITEM -->");

                } else {

                    out.println("<select name=item_id onchange=\"load_times(this.options[this.selectedIndex].value)\">");
                    out.println("<option value=\"0\">CHOOSE...</option>");

                }

                if (!do_load) {

                    rs.beforeFirst();

                    while (rs.next()) {

                        Common_Config.buildOption(rs.getInt("activity_id"), rs.getString("activity_name"), item_id, out);

                    }

                }
                stmt.close();

                out.println("");
                out.println("</select>");

            } catch (Exception exc) {

                out.println("<p>ERROR:" + exc.toString() + "</p>");

            }


        }

        out.println("</form>");

        out.println("<p><a href=\"Member_genrez\">Reset</a></p>");

        try {
            con.close();
        } catch (Exception ignore) {}


        if (do_load) out.println("<script>load_times(" + item_id + ")</script>");


        //out.println("<iframe name=ifSheet src=\"\" style=\"width:640px height:480px\"></iframe>");
    */

    out.close();
  }
  /** Business logic to execute. */
  public final Response executeCommand(
      Object inputPar,
      UserSessionParameters userSessionPars,
      HttpServletRequest request,
      HttpServletResponse response,
      HttpSession userSession,
      ServletContext context) {
    String serverLanguageId = ((JAIOUserSessionParameters) userSessionPars).getServerLanguageId();

    PreparedStatement pstmt = null;
    Connection conn = null;
    try {
      conn = ConnectionManager.getConnection(context);

      // fires the GenericEvent.CONNECTION_CREATED event...
      EventsManager.getInstance()
          .processEvent(
              new GenericEvent(
                  this,
                  getRequestName(),
                  GenericEvent.CONNECTION_CREATED,
                  (JAIOUserSessionParameters) userSessionPars,
                  request,
                  response,
                  userSession,
                  context,
                  conn,
                  inputPar,
                  null));

      GridParams pars = (GridParams) inputPar;

      BigDecimal rootProgressiveHIE01 =
          (BigDecimal) pars.getOtherGridParams().get(ApplicationConsts.ROOT_PROGRESSIVE_HIE01);
      BigDecimal progressiveHIE01 =
          (BigDecimal) pars.getOtherGridParams().get(ApplicationConsts.PROGRESSIVE_HIE01);
      BigDecimal progressiveHIE02 =
          (BigDecimal) pars.getOtherGridParams().get(ApplicationConsts.PROGRESSIVE_HIE02);
      Boolean productsOnly =
          (Boolean) pars.getOtherGridParams().get(ApplicationConsts.PRODUCTS_ONLY);
      Boolean compsOnly =
          (Boolean) pars.getOtherGridParams().get(ApplicationConsts.COMPONENTS_ONLY);

      HierarchyLevelVO vo =
          (HierarchyLevelVO) pars.getOtherGridParams().get(ApplicationConsts.TREE_FILTER);
      if (vo != null) {
        progressiveHIE01 = vo.getProgressiveHIE01();
        progressiveHIE02 = vo.getProgressiveHie02HIE01();
      }

      // retrieve companies list...
      ArrayList companiesList =
          ((JAIOUserSessionParameters) userSessionPars).getCompanyBa().getCompaniesList("ITM01");
      String companies = "";
      for (int i = 0; i < companiesList.size(); i++)
        companies += "'" + companiesList.get(i).toString() + "',";
      companies = companies.substring(0, companies.length() - 1);

      String sql =
          "select ITM01_ITEMS.COMPANY_CODE_SYS01,ITM01_ITEMS.ITEM_CODE,SYS10_TRANSLATIONS.DESCRIPTION,ITM01_ITEMS.PROGRESSIVE_HIE02,ITM01_ITEMS.MIN_SELLING_QTY_UM_CODE_REG02,"
              + "ITM01_ITEMS.PROGRESSIVE_HIE01,ITM01_ITEMS.SERIAL_NUMBER_REQUIRED,REG02_MEASURE_UNITS.DECIMALS "
              + " from ITM01_ITEMS,SYS10_TRANSLATIONS,REG02_MEASURE_UNITS where "
              + "ITM01_ITEMS.PROGRESSIVE_HIE02=? and "
              + "ITM01_ITEMS.PROGRESSIVE_SYS10=SYS10_TRANSLATIONS.PROGRESSIVE and "
              + "SYS10_TRANSLATIONS.LANGUAGE_CODE=? and "
              + "ITM01_ITEMS.COMPANY_CODE_SYS01 in ("
              + companies
              + ") and "
              + "ITM01_ITEMS.ENABLED='Y' and "
              + "ITM01_ITEMS.MIN_SELLING_QTY_UM_CODE_REG02=REG02_MEASURE_UNITS.UM_CODE ";

      if (productsOnly != null && productsOnly.booleanValue())
        sql += " and ITM01_ITEMS.MANUFACTURE_CODE_PRO01 is not null ";

      if (compsOnly != null && compsOnly.booleanValue())
        sql += " and ITM01_ITEMS.MANUFACTURE_CODE_PRO01 is null ";

      if (rootProgressiveHIE01 == null || !rootProgressiveHIE01.equals(progressiveHIE01)) {
        // retrieve all subnodes of the specified node...
        pstmt =
            conn.prepareStatement(
                "select HIE01_LEVELS.PROGRESSIVE,HIE01_LEVELS.PROGRESSIVE_HIE01,HIE01_LEVELS.LEV from HIE01_LEVELS "
                    + "where ENABLED='Y' and PROGRESSIVE_HIE02=? and PROGRESSIVE>=? "
                    + "order by LEV,PROGRESSIVE_HIE01,PROGRESSIVE");
        pstmt.setBigDecimal(1, progressiveHIE02);
        pstmt.setBigDecimal(2, progressiveHIE01);
        ResultSet rset = pstmt.executeQuery();

        HashSet currentLevelNodes = new HashSet();
        HashSet newLevelNodes = new HashSet();
        String nodes = "";
        int currentLevel = -1;
        while (rset.next()) {
          if (currentLevel != rset.getInt(3)) {
            // next level...
            currentLevel = rset.getInt(3);
            currentLevelNodes = newLevelNodes;
            newLevelNodes = new HashSet();
          }
          if (rset.getBigDecimal(1).equals(progressiveHIE01)) {
            newLevelNodes.add(rset.getBigDecimal(1));
            nodes += rset.getBigDecimal(1) + ",";
          } else if (currentLevelNodes.contains(rset.getBigDecimal(2))) {
            newLevelNodes.add(rset.getBigDecimal(1));
            nodes += rset.getBigDecimal(1) + ",";
          }
        }
        rset.close();
        pstmt.close();
        if (nodes.length() > 0) nodes = nodes.substring(0, nodes.length() - 1);
        sql += " and PROGRESSIVE_HIE01 in (" + nodes + ")";
      }

      Map attribute2dbField = new HashMap();
      attribute2dbField.put("companyCodeSys01ITM01", "ITM01_ITEMS.COMPANY_CODE_SYS01");
      attribute2dbField.put("itemCodeITM01", "ITM01_ITEMS.ITEM_CODE");
      attribute2dbField.put("descriptionSYS10", "SYS10_TRANSLATIONS.DESCRIPTION");
      attribute2dbField.put("progressiveHie02ITM01", "ITM01_ITEMS.PROGRESSIVE_HIE02");
      attribute2dbField.put(
          "minSellingQtyUmCodeReg02ITM01", "ITM01_ITEMS.MIN_SELLING_QTY_UM_CODE_REG02");
      attribute2dbField.put("progressiveHie01ITM01", "ITM01_ITEMS.PROGRESSIVE_HIE01");
      attribute2dbField.put("serialNumberRequiredITM01", "ITM01_ITEMS.SERIAL_NUMBER_REQUIRED");
      attribute2dbField.put("decimalsREG02", "REG02_MEASURE_UNITS.DECIMALS");

      ArrayList values = new ArrayList();
      values.add(progressiveHIE02);
      values.add(serverLanguageId);

      // read from ITM01 table...
      Response answer =
          QueryUtil.getQuery(
              conn,
              userSessionPars,
              sql,
              values,
              attribute2dbField,
              GridItemVO.class,
              "Y",
              "N",
              context,
              pars,
              50,
              true);

      // fires the GenericEvent.BEFORE_COMMIT event...
      EventsManager.getInstance()
          .processEvent(
              new GenericEvent(
                  this,
                  getRequestName(),
                  GenericEvent.BEFORE_COMMIT,
                  (JAIOUserSessionParameters) userSessionPars,
                  request,
                  response,
                  userSession,
                  context,
                  conn,
                  inputPar,
                  answer));
      return answer;

    } catch (Throwable ex) {
      Logger.error(
          userSessionPars.getUsername(),
          this.getClass().getName(),
          "executeCommand",
          "Error while fetching items list",
          ex);
      return new ErrorResponse(ex.getMessage());
    } finally {
      try {
        pstmt.close();
      } catch (Exception ex2) {
      }
      try {
        ConnectionManager.releaseConnection(conn, context);
      } catch (Exception ex1) {
      }
    }
  }
  @Override
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {

    // create the workbook, its worksheet, and its title row
    Workbook workbook = new HSSFWorkbook();
    Sheet sheet = workbook.createSheet("User table");
    Row row = sheet.createRow(0);
    row.createCell(0).setCellValue("The User table");

    // create the header row
    row = sheet.createRow(2);
    row.createCell(0).setCellValue("UserID");
    row.createCell(1).setCellValue("LastName");
    row.createCell(2).setCellValue("FirstName");
    row.createCell(3).setCellValue("Email");

    try {
      // read database rows
      ConnectionPool pool = ConnectionPool.getInstance();
      Connection connection = pool.getConnection();
      Statement statement = connection.createStatement();
      String query = "SELECT * FROM User ORDER BY UserID";
      ResultSet results = statement.executeQuery(query);

      // create spreadsheet rows
      int i = 3;
      while (results.next()) {
        row = sheet.createRow(i);
        row.createCell(0).setCellValue(results.getInt("UserID"));
        row.createCell(1).setCellValue(results.getString("LastName"));
        row.createCell(2).setCellValue(results.getString("FirstName"));
        row.createCell(3).setCellValue(results.getString("Email"));
        i++;
      }
      results.close();
      statement.close();
      connection.close();
    } catch (SQLException e) {
      this.log(e.toString());
    }

    // set response object headers
    response.setHeader("content-disposition", "attachment; filename=users.xls");
    response.setHeader("cache-control", "no-cache");

    // get the output stream
    String encodingString = request.getHeader("accept-encoding");
    OutputStream out;
    if (encodingString != null && encodingString.contains("gzip")) {
      out = new GZIPOutputStream(response.getOutputStream());
      response.setHeader("content-encoding", "gzip");
      // System.out.println("User table encoded with gzip");
    } else {
      out = response.getOutputStream();
      // System.out.println("User table not encoded with gzip");
    }

    // send the workbook to the browser
    workbook.write(out);
    out.close();
  }
  public void _jspService(
      final javax.servlet.http.HttpServletRequest request,
      final javax.servlet.http.HttpServletResponse response)
      throws java.io.IOException, javax.servlet.ServletException {

    final javax.servlet.jsp.PageContext pageContext;
    javax.servlet.http.HttpSession session = null;
    final javax.servlet.ServletContext application;
    final javax.servlet.ServletConfig config;
    javax.servlet.jsp.JspWriter out = null;
    final java.lang.Object page = this;
    javax.servlet.jsp.JspWriter _jspx_out = null;
    javax.servlet.jsp.PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html");
      pageContext =
          _jspxFactory.getPageContext(
              this,
              request,
              response,
              "ReportErrorPage.jsp?page=EditTargetReportForm.jsp",
              true,
              8192,
              true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(
          request, response, "header.jsp", out, false);
      out.write(' ');
      out.write('\n');
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\t<!-- files for JqxWidget grid  -->\n");
      out.write(
          "    <link rel=\"stylesheet\" href=\"js/jqwidgets/styles/jqx.base.css\" type=\"text/css\" />\n");
      out.write(
          "    <link rel=\"stylesheet\" href=\"js/jqwidgets/styles/jqx.darkblue.css\" type=\"text/css\" />\n");
      out.write(
          "\t<link rel=\"stylesheet\" href=\"js/jqwidgets/styles/jqx.ui-redmond.css\" type=\"text/css\" />\n");
      out.write("\t\n");
      out.write(
          "    <script type=\"text/javascript\" src=\"js/jqwidgets/gettheme.js\"></script>\n");
      out.write("\t<script type=\"text/javascript\" src=\"js/jquery-1.10.2.min.js\"></script>\n");
      out.write("    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxcore.js\"></script>\n");
      out.write("    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxdata.js\"></script>\n");
      out.write(
          "    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxbuttons.js\"></script>\n");
      out.write(
          "    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxscrollbar.js\"></script>\n");
      out.write(
          "    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxlistbox.js\"></script>\n");
      out.write(
          "    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxcalendar.js\"></script>\n");
      out.write(
          "    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxdatetimeinput.js\"></script>\n");
      out.write("    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxgrid.js\"></script>\n");
      out.write(
          "    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxgrid.filter.js\"></script>\n");
      out.write(
          "    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxgrid.selection.js\"></script>\n");
      out.write(
          "    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxgrid.sort.js\"></script>\n");
      out.write(
          "    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxgrid.pager.js\"></script>\n");
      out.write(
          "     <script type=\"text/javascript\" src=\"js/jqwidgets/jqxmenu.js\"></script>\n");
      out.write(
          "    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxlistbox.js\"></script>\n");
      out.write(
          "    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxdropdownlist.js\"></script>\n");
      out.write(
          "    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxdata.export.js\"></script> \n");
      out.write(
          "    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxgrid.export.js\"></script> \n");
      out.write(
          "    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxgrid.aggregates.js\"></script>  \n");
      out.write(
          "    <script type=\"text/javascript\" src=\"js/jqwidgets/jqxgrid.grouping.js\"></script> \n");
      out.write("\n");
      out.write("\n");
      out.write("\t\n");
      out.write("\t");

      session.getAttribute("UserName").toString();
      // System.out.println("session bachka maapping : "+session +" \n user
      // "+session.getAttribute("UserName").toString());

      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("<script src=\"js/editCustomer_details.js\"> </script> \n");
      out.write("\n");
      out.write("<script type=\"text/javascript\" src=\"js/popup.js\"></script>\n");
      out.write("<style>\n");
      out.write("hr {\n");
      out.write("color: #f00;\n");
      out.write("background-color: #f00;\n");
      out.write("height: 3px;\n");
      out.write("}\n");
      out.write("#selected_order{\n");
      out.write("width: 40%;\n");
      out.write("max-height: 300px;\n");
      out.write("border: 1px solid black; \n");
      out.write("background-color: #ECFB99;\n");
      out.write("float: right;\n");
      out.write("margin-top: 30px;\n");
      out.write("overflow: auto;\n");
      out.write("margin-right: 2%;\n");
      out.write("padding: 5px;\n");
      out.write("}\n");
      out.write("</style>\n");
      out.write("<script>\n");
      out.write("\t\n");
      out.write("\tfunction checkField(){\n");
      out.write("\t\tif(document.myform.chckall.checked==true){\n");
      out.write("\t\t\tshowHint();\n");
      out.write("\t\t}\n");
      out.write("\t\telse{\t\tvar c_date1,c_date2,u_date2,u_date1;\n");
      out.write("\t\t\t\tif(!($(\"#createDate2\").jqxDateTimeInput('disabled'))){\n");
      out.write("\t\t\t\tc_date1 = $('#createDate1').jqxDateTimeInput('getText');\n");
      out.write("\t\t\t\tc_date2 = $('#createDate2').jqxDateTimeInput('getText');\n");
      out.write("\t\t\t}\n");
      out.write("\t\t\t\n");
      out.write("\t\t\tif(!($(\"#updateDate2\").jqxDateTimeInput('disabled'))){\n");
      out.write("\t\t\t\tu_date1 = $('#updateDate1').jqxDateTimeInput('getText');\n");
      out.write("\t\t\t\tu_date2 = $('#updateDate2').jqxDateTimeInput('getText');\n");
      out.write("\t\t\t}\t    \n");
      out.write("\t\t    showHint();\t\t  \n");
      out.write("\t    }\n");
      out.write("\t}\n");
      out.write("\tfunction showMsg(){\n");
      out.write("\t  \t document.myform.action=\"HomeForm.jsp\";\n");
      out.write("\t   \t document.myform.submit();\n");
      out.write("\t}\n");
      out.write("\tfunction Clear(){\n");
      out.write("\t\t\n");
      out.write("\t\ttry{\n");
      out.write("\t\t\tdocument.getElementById(\"order_number\").focus();\n");
      out.write("\t\t} catch (exp){}\n");
      out.write("\t\t\n");
      out.write("\t\t\n");
      out.write("\t\t\n");
      out.write("\t\tdocument.myform.custCode.value=\"\";\n");
      out.write("\t\tdocument.myform.phonenumber.value=\"\";\n");
      out.write("\t\tdocument.myform.custName.value=\"\";\n");
      out.write("\t\tdocument.myform.nameString.value=\"\";\t\t\n");
      out.write("\t\tdocument.myform.Building.value=\"\";\n");
      out.write("\t\tdocument.myform.Building_no.value=\"\";\n");
      out.write("\t\tdocument.myform.wing.value=\"\";\n");
      out.write("\t\tdocument.myform.block.value=\"\";\n");
      out.write("\t\tdocument.myform.add1.value=\"\";\n");
      out.write("\t\tdocument.myform.add2.value=\"\";\n");
      out.write("\t\tdocument.myform.area.value=\"\";\n");
      out.write("\t\tdocument.myform.station.value=\"\";\n");
      out.write("\t\t\n");
      out.write("\t\tdocument.myform.selmonth.value=\"\";\n");
      out.write("\t\t\n");
      out.write(
          "\t\t$(\"#createDate1\").jqxDateTimeInput({theme:'ui-redmond',width: '250px', height: '25px',max:new Date(),formatString: \"yyyy-MM-dd\"});\n");
      out.write(
          "\t\t$(\"#createDate2\").jqxDateTimeInput({theme:'ui-redmond',width: '250px', height: '25px',min:new Date(),max:new Date(),formatString: \"yyyy-MM-dd\",value:new Date()});\n");
      out.write("\t\t$(\"#createDate2\").jqxDateTimeInput({disabled: true});\n");
      out.write("\t\t\n");
      out.write("\t\t\n");
      out.write(
          "\t\t$(\"#updateDate1\").jqxDateTimeInput({theme:'ui-redmond',width: '250px', height: '25px',max:new Date(),formatString: \"yyyy-MM-dd\"});\n");
      out.write(
          "\t\t$(\"#updateDate2\").jqxDateTimeInput({theme:'ui-redmond',width: '250px', height: '25px',min:new Date(),max:new Date(),formatString: \"yyyy-MM-dd\",value:new Date()});\n");
      out.write("\t\t$(\"#updateDate2\").jqxDateTimeInput({disabled: true});\n");
      out.write("\t\t\n");
      out.write("\t\t$('#createDate1').on('close', function (event) {\n");
      out.write("\t\t // Some code here. \n");
      out.write("\t\t \t$(\"#createDate2\").jqxDateTimeInput({disabled: false});\n");
      out.write(
          "\t\t \t$(\"#createDate2\").jqxDateTimeInput({min: $('#createDate1').jqxDateTimeInput('getDate')});\n");
      out.write(" \t\t}); \t\n");
      out.write(" \t\t\n");
      out.write(" \t\t$('#updateDate1').on('close', function (event) {\n");
      out.write("\t\t // Some code here. \n");
      out.write("\t\t \t$(\"#updateDate2\").jqxDateTimeInput({disabled: false});\n");
      out.write(
          "\t\t \t$(\"#updateDate2\").jqxDateTimeInput({min: $('#updateDate1').jqxDateTimeInput('getDate')});\n");
      out.write(" \t\t}); \t\n");
      out.write("\t\t\n");
      out.write("\t\tfunEnabled();\n");
      out.write("\t}\n");
      out.write("\t\n");
      out.write("function ckeckEmpty(){\n");
      out.write("\tif(document.getElementById(\"order_number\").value == \"\"){\n");
      out.write("\t\talert(\"Please Enter Order Number\");\n");
      out.write("\t\tdocument.getElementById(\"order_number\").focus();\n");
      out.write("\t\treturn false;\n");
      out.write("\t} else {\n");
      out.write("\t\treturn true;\n");
      out.write("\t}\n");
      out.write("}\n");
      out.write("\n");
      out.write("\n");
      out.write("</script>\n");

      String call_type = request.getParameter("call_type");
      if (call_type == null) {
        call_type = "";
      }
      if (call_type.equals("search_payment")) {
        String m = "<< Show List";

        out.write("\n");
        out.write("\t\t\t<div id=\"selected_order\">\n");
        out.write("\t\t\t\t<b>Selected orders</b>\n");
        out.write(
            "\t\t\t\t<form action=\"PrintSelectedCustPayment.jsp\" method=\"get\" id=\"submit_form\">\n");
        out.write(
            "\t\t\t\t<table style=\"width: 100%;border-collapse: collapse;\" border=1 id=\"selected_order_table\">\n");
        out.write("\t\t\t\t<tr>\n");
        out.write("\t\t\t\t\t<th style=\"width: 20%;\">Order Number</th>\n");
        out.write("\t\t\t\t\t<th style=\"width: 35%;\">Cust Name</th>\n");
        out.write("\t\t\t\t\t<th style=\"width: 20%;\">Balance</th>\n");
        out.write("\t\t\t\t\t<th style=\"width: 25%;\">&nbsp;</th>\n");
        out.write("\t\t\t\t</tr>\n");
        out.write("\t\t\t\t</table>\n");
        out.write("\t\t\t\t<table style=\"width: 100%;\" border=1 id=\"insert_table\">\n");
        out.write("\t\t\t\t</table>\n");
        out.write(
            "\t\t\t\t <input type=\"text\" readonly=\"readonly\" name=\"order_count\" id=\"order_count_id\" size=\"3\" value=\"0\" style=\"background-color :#ECFB99 ;\"/> orders selected to print.\n");
        out.write(
            "\t\t\t\t<input type=\"submit\" onclick=\" return printSelectedInformation()\" value=\"Print\" style=\"float: right;\"/>\n");
        out.write("\t\t\t\t</form>\n");
        out.write("\t\t\t</div>\n");
        out.write("\t\t");
      }
      if (!call_type.equals("search_payment") || !call_type.equals("communication")) {

        out.write("\n");
        out.write("<center>\n");
      }
      out.write("\n");
      out.write("<fieldset style=\"width: 55%;\"><legend>\n");

      String msg = request.getParameter("msg");
      if (call_type.equals("receive_payment")) {
        out.print("<h3>Search Customer To Receive Payment</h3>");
      } else if (call_type.equals("search_payment")) {
        out.print("<h3>Search Customer To See Pending</h3>");
      } else if (call_type.equals("communication")) {
        out.print("<h3>Search Customer To Communicate</h3>");
      } else {
        out.print("<h3>Search Customer</h3>");
      }

      out.write("\n");
      out.write("</legend>\n");

      if (call_type.equals("receive_payment")) {

        out.write("\n");
        out.write(
            "\t\t<input type = \"radio\" name = \"radio\" onclick=\"ChangeCriteria('order')\" checked=\"checked\"/>Search By Order Number\n");
        out.write(
            "\t\t<input type = \"radio\" name = \"radio\" onclick=\"ChangeCriteria('cust')\"/>Search By Customer Detail\n");
        out.write("\t");
      }
      if (call_type.equals("receive_payment")) {

        out.write("\n");
        out.write("\t<br/><br/>\n");
        out.write("<form id=\"myform1\" action=\"SearchCustUsingOrderNo.jsp\" method=\"get\">\n");
        out.write("\t");

        if (msg != null) {
          out.print("<i><font color=red>No Matching Record Found</font></i><br/><br/>");
        }

        out.write("\n");
        out.write(
            "\tEnter Order Number :&nbsp;&nbsp;<input type = \"text\" name = \"order_number\" value=\"\" id =\"order_number\" onkeypress=\"return isNumberKey(event)\"/>\n");
        out.write(
            "\t<input type = \"submit\" value=\"Search\" onclick=\"return ckeckEmpty();\"/>\n");
        out.write("\n");
        out.write("<br/>\n");
        out.write("</form>\n");
        out.write("<form name=\"myform\" method=\"post\" id=\"myform\" style=\"display: none\">\n");
      } else {
        out.write("\n");
        out.write("<form name=\"myform\" method=\"post\" id=\"myform\" >\n");
      }
      out.write("\n");
      out.write("\t<table style=\"width: 100%;\">\n");
      out.write("\t\t<tr style=\"width: 100%;\">\n");
      out.write(
          "\t\t\t<td align=\"center\" colspan=3><b><font color=\"blue\">&nbspA</font>ll Customers List &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp\n");
      out.write(
          "\t\t\t<input type=\"CheckBox\" name=\"chckall\" accesskey=\"a\" onClick=\"funEnabled();\"></td>\n");
      out.write("\t\t</tr>\t\t\n");
      out.write("\t\t<tr style=\"width: 100%;\">\n");
      out.write("\t\t\t<td colspan=3>\n");
      out.write("\t\t\t<div id=\"div4\" style=\"width: 100%;\" >\n");
      out.write("\t\t\t\t<table>\t\t\t\t\n");
      out.write("\t\t\t\t\t<tr>\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\">\n");
      out.write("\t\t\t\t\t\t\t<b><font color=\"blue\">C</font>ustomer Code</b>\n");
      out.write("\t\t\t\t\t\t</td>\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write(
          "\t\t\t\t\t\t<td style=\"width: 29%;\"><input style=\"width: 97%;\" type=\"text\" name=\"custCode\" accesskey=\"c\"></td>\n");
      out.write("\t\t\t\t\t\t");
      if (call_type.equals("search_payment") || call_type.equals("communication")) {
        out.write("\n");
        out.write("\t\t\t\t\t\t<td style=\"width: 8%;\" align=\"left\"></td>\n");
        out.write("\t\t\t\t\t\t\n");
        out.write("\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\">\n");
        out.write("\t\t\t\t\t\t\t<b>O<font color=\"blue\">r</font>der Number</b>\n");
        out.write("\t\t\t\t\t\t</td>\n");
        out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
        out.write(
            "\t\t\t\t\t\t<td style=\"width: 29%;\"><input style=\"width: 97%;\" type=\"text\" name=\"ordernumber\" accesskey=\"c\"></td>\n");
        out.write("\t\t\t\t\t\t");
      }
      out.write("\n");
      out.write("\t\t\t\t\t</tr>\n");
      out.write("\t\t\t\t\t<tr>\n");
      out.write(
          "\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b>Customer <font color=\"blue\">N</font>ame</b></td>\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write(
          "\t\t\t\t\t\t<td style=\"width: 29%;\"><input style=\"width: 97%;\" type=\"text\" name=\"custName\"  align=\"right\" accesskey=\"n\"></td>\n");
      out.write("\t\t\t\t\t\t\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 8%;\" align=\"left\"></td>\n");
      out.write("\t\t\t\t\t\t\n");
      out.write(
          "\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b><font color=\"blue\">P</font>hone Number</b></td>\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write(
          "\t\t\t\t\t\t<td style=\"width: 29%;\"><input style=\"width: 97%;\" type=\"text\" name=\"phonenumber\" size=\"22\" align=\"right\" colspan=\"2\" accesskey=\"p\"></td>\n");
      out.write("\t\t\t\t\t\t\n");
      out.write("\t\t\t\t\t</tr>\n");
      out.write("\t\t\t\t\t<tr>\n");
      out.write(
          "\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b>M<font color=\"blue\">o</font>bile Number</b></td>\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write(
          "\t\t\t\t\t\t<td><input style=\"width: 97%;\" type=\"text\" name=\"mobilenumber\" size=\"22\" align=\"right\" colspan=\"2\" accesskey=\"o\"></td>\n");
      out.write("\t\t\t\t\t\t\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 8%;\" align=\"left\"></td>\n");
      out.write("\t\t\t\t\t\t\n");
      out.write(
          "\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b>Na<font color=\"blue\">m</font>e String</b></td>\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write(
          "\t\t\t\t\t\t<td><input style=\"width: 97%;\" style=\"width: 100%;\" type=\"text\" name=\"nameString\" size=\"22\"  align=\"right\" accesskey=\"m\" colspan=\"2\"></td>\n");
      out.write("\t\t\t\t\t</tr>\n");
      out.write("\t\t\t\t\t<tr>\n");
      out.write(
          "\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b><font color=\"blue\">B</font>uilding</b></td>\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write(
          "\t\t\t\t\t\t<td><input style=\"width: 97%;\" type=\"text\" name=\"Building\" accesskey=\"b\" align=\"right\"></b></td>\n");
      out.write("\t\t\t\t\t\t\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 8%;\" align=\"left\"></td>\n");
      out.write("\t\t\t\t\t\t\n");
      out.write(
          "\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b>Building <font color=\"blue\">N</font>o.</b></td>\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write(
          "\t\t\t\t\t\t<td><input style=\"width: 97%;\" type=\"text\" name=\"Building_no\"  size=\"22\"  accesskey=\"o\"></b></td>\n");
      out.write("\t\t\t\t\t</tr>\n");
      out.write("\t\t\t\t\t<tr>\n");
      out.write(
          "\t\t\t\t\t    <td style=\"width: 15%;\" align=\"left\"><b><font color=\"blue\">W</font>ing</b></td>\n");
      out.write("\t\t\t\t\t    <td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write(
          "\t\t\t\t\t    <td><input style=\"width: 97%;\" type =\"text\" name=\"wing\" accesskey=\"w\" ></td>\n");
      out.write("\t\t\t\t\t    \n");
      out.write("\t\t\t\t\t    <td style=\"width: 8%;\" align=\"left\"></td>\n");
      out.write("\t\t\t\t\t    \n");
      out.write(
          "\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b><font color=\"blue\">F</font>lat No.</b></td>\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write(
          "\t\t\t\t\t\t<td><input style=\"width: 97%;\" type =\"text\" name=\"block\"  size=\"22\" accesskey=\"f\" align=\"right\">\n");
      out.write("\t\t\t\t\t\t</tr>\n");
      out.write("\t\t\t\t\t<tr>\n");
      out.write(
          "\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b>Addr<font color=\"blue\">e</font>ss1</b></td>\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write(
          "\t\t\t\t\t\t<td><input style=\"width: 97%;\" type =\"text\" accesskey=\"e\" name=\"add1\"></td>\n");
      out.write("\t\t\t\t\t\t\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 8%;\" align=\"left\"></td>\n");
      out.write("\t\t\t\t\t\t\n");
      out.write(
          "\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b>A<font color=\"blue\">d</font>dress2</b></td>\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write(
          "\t\t\t\t\t\t<td><input style=\"width: 97%;\" type =\"text\" accesskey=\"d\" name=\"add2\" size=\"22\"></td>\n");
      out.write("\t\t\t\t\t</tr>\n");
      out.write("\t\t\t\t\t<tr >\n");
      out.write(
          "\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b>A<font color=\"blue\">r</font>ea</b></td>\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write("\t\t\t\t\t\t<td>\n");
      out.write("\t\t\t\t\t\t");

      String name;
      try {
        Context initContext = new InitialContext();
        Context envContext = (Context) initContext.lookup("java:/comp/env");
        // DataSource ds = (DataSource)envContext.lookup("jdbc/js");
        DataSource ds = (DataSource) envContext.lookup("jdbc/re");
        Connection conn = ds.getConnection();
        Statement stmt = conn.createStatement();
        ResultSet rs =
            stmt.executeQuery(
                "select value from code_table where category='AREA' order by value asc");

        out.write("\n");
        out.write("\t\t\t\t\t\t\t<SELECT style=\"width: 97%;\" name=\"area\">\n");
        out.write("\t\t\t\t\t\t\t\t<OPTION VALUE=\"\"> Select Area </OPTION>\n");
        out.write("\t\t\t\t\t\t");

        while (rs.next()) {
          name = rs.getString(1);

          out.write("\n");
          out.write("\t\t\t\t\t\t\t\t<OPTION VALUE=\"");
          out.print(name);
          out.write('"');
          out.write('>');
          out.write(' ');
          out.print(name);
          out.write(" </OPTION>\n");
          out.write("\t\t\t\t\t\t");
        }

        out.write("\n");
        out.write("\t\t\t\t\t\t\t</SELECT>\n");
        out.write("\t\t\t\t\t\t</td>\t\n");
        out.write("\t\t\t\t\t\t\n");
        out.write("\t\t\t\t\t\t<td style=\"width: 8%;\" align=\"left\"></td>\n");
        out.write("\t\t\t\n");
        out.write(
            "\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b>Payment Type</b></td>\n");
        out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
        out.write("\t\t\t\t\t\t<td>\n");
        out.write("\t\t\t\t\t\t\t<SELECT style=\"width: 97%;\" name=\"payment\" align=\"left\">\n");
        out.write("\t\t\t\t\t\t\t\t<OPTION selected VALUE=\"\"> Select Type </OPTION>\n");
        out.write("\t\t\t\t\t\t\t\t<OPTION VALUE=\"NoType\"> No Type </OPTION>\n");
        out.write("\t\t\t\t\t\t");

        ResultSet rs2 =
            stmt.executeQuery("SELECT payment_type_code, payment_type_desc FROM payment_type");
        while (rs2.next()) {

          out.write("\t\n");
          out.write("\t\t\t\t\t\t\t\t<OPTION VALUE=\"");
          out.print(rs2.getString(1));
          out.write('"');
          out.write('>');
          out.write(' ');
          out.print(rs2.getString(2));
          out.write(" </OPTION>\n");
          out.write("\t\t\t\t\t\t");
        }
        rs2.close();
        stmt.close();
        conn.close();
      } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
      }

      out.write("\n");
      out.write("\t\t\t\t\t\t\t</SELECT>\n");
      out.write("\t\t\t\t\t\t</td>\n");
      out.write("\t\t\t\t\t</tr>\n");
      out.write("\t\t\t\t\t<tr>\n");
      out.write(
          "\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b>Create<font color=\"blue\">D</font>ate</b></td>\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write("\t\t\t\t\t\t<td>\n");
      out.write(
          "\t\t\t\t\t\t\t<!-- <input type =\"text\" accesskey=\"d\" name=\"c_date1\" size=\"15\" style=\"width: 79%;\">\n");
      out.write(
          "\t\t\t\t\t\t\t<input type=\"button\" onClick=\"c1.popup('c_date1');\" value=\"...\" style=\"width: 15%;\"/> -->\n");
      out.write("\t\t\t\t\t\t\t<div id='createDate1'></div>\n");
      out.write("\t\t\t\t\t\t</td>\n");
      out.write("\t\t\t\t\t\t\t\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 8%;\" align=\"left\"></td>\n");
      out.write("\t\t\t\t\t\t\t\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b>And</b></td>\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write("\t\t\t\t\t\t<td> \n");
      out.write(
          "\t\t\t\t\t\t\t<!-- <input type =\"text\" name=\"c_date2\" size=\"15\" style=\"width: 79%;\">\n");
      out.write(
          "\t\t\t\t\t\t\t<input type=\"button\" onClick=\"c1.popup('c_date2');\" value=\"...\" style=\"width: 15%;\"/> -->\n");
      out.write("\t\t\t\t\t\t\t<div id='createDate2'></div>\n");
      out.write("\t\t\t\t\t\t\t\n");
      out.write("\t\t\t\t\t\t</td>\n");
      out.write("\t\t\t\t\t</tr>\n");
      out.write("\t\t\t\t\t<tr>\n");
      out.write(
          "\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b><font color=\"blue\">U</font>pdate Date</b></td>\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write("\t\t\t\t\t\t<td>\n");
      out.write(
          "\t\t\t\t\t\t\t<!-- <input type =\"text\" accesskey=\"u\" name=\"u_date1\" size=\"15\" style=\"width: 79%;\"/>\n");
      out.write(
          "\t\t\t\t\t\t\t<input type=\"button\" onClick=\"c1.popup('u_date1');\" value=\"...\" style=\"width: 15%;\"/> -->\n");
      out.write("\t\t\t\t\t\t\t<div id=\"updateDate1\"></div>\n");
      out.write("\t\t\t\t\t\t</td>\n");
      out.write("\t\t\t\t\t\t\t\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 8%;\" align=\"left\"></td>\n");
      out.write("\t\t\t\t\t\t\t\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b>And</b></td>\n");
      out.write("\t\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write("\t\t\t\t\t\t<td> \n");
      out.write(
          "\t\t\t\t\t\t\t<!-- <input type =\"text\" name=\"u_date2\" size=\"15\" style=\"width: 79%;\"/>\n");
      out.write(
          "\t\t\t\t\t\t\t<input type=\"button\" onClick=\"c1.popup('u_date2');\" value=\"...\" style=\"width: 15%;\"/> -->\n");
      out.write("\t\t\t\t\t\t\t<div id='updateDate2'></div>\n");
      out.write("\t\t\t\t\t\t</td>\n");
      out.write("\t\t\t\t\t</tr>\n");
      out.write("\t\t\t\t\t<tr>\n");
      out.write(
          "\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b><font color=\"blue\">S</font>tation</b></td>\n");
      out.write("\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write(
          "\t\t\t\t\t<td><input style=\"width: 97%;\" type =\"text\"  size=\"22\" accesskey=\"d\" name=\"station\"></td>\n");
      out.write("\t\t\t\t\t\t\n");
      out.write("\t\t\t\t\t<td style=\"width: 8%;\" align=\"left\"></td>\n");
      out.write("\t\t\t\t\t\t\n");
      out.write("\t\t\t\t\t<td style=\"width: 15%;\" align=\"left\"><b>Last Order Days</b></td>\n");
      out.write("\t\t\t\t\t<td style=\"width: 1%;\" align=\"left\">:</td>\n");
      out.write(
          "\t\t\t\t\t<td><input style=\"width: 97%;\" type=\"text\" name=\"selmonth\"/></td></tr>\n");
      out.write("\t\t\t\t</table></div>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t</tr>\n");
      out.write("\t\t\t\n");
      out.write("\t\t<tr>\n");
      out.write("\t\t\t<td align=\"center\" colspan=4>\n");
      out.write(
          "\t\t\t\t<input type=\"submit\" name=\"search\"  title=\"Press <Enter>\" value=\"Search <Enter>\" accesskey=\"s\" onclick=\"checkField();return false;\"/>\n");
      out.write(
          "\t\t\t\t<input type=\"reset\" name=\"clear\" title=\"Press <Alt+c>\" tabindex=\"1\" value=\"Clear <Alt+c>\" accesskey=\"c\" onclick=\"document.getElementById('txtHint').innerHTML='';\"/>\n");
      out.write(
          "\t\t\t\t<INPUT type=BUTTON value=\"Cancel <Alt+c>\" accesskey=\"c\" onClick=\"showMsg();\"/></center>\n");
      out.write("\t\t\t</td>\n");
      out.write("\t\t</tr>\n");
      out.write("\t</table>\n");
      out.write("\t</fieldset>\n");
      out.write("\t<input  type=\"hidden\" name=\"hchckall\" value=\"1\">\n");
      out.write("\t<input type=\"hidden\" name=\"call_type\" value=\"");
      out.print(call_type);
      out.write("\"/>\n");
      out.write("<script>\n");
      out.write("function funEnabled(){\n");
      out.write("\t    if (document.myform.chckall.checked==true){\n");
      out.write("\t\t\tdocument.getElementById('div4').style.visibility=\"hidden\";\n");
      out.write("\t\t\tdocument.myform.hchckall.value=1;\t\t\n");
      out.write("\t\t\t$(\"#createDate2\").jqxDateTimeInput({disabled: true});\n");
      out.write("\t\t\t$(\"#updateDate2\").jqxDateTimeInput({disabled: true});\n");
      out.write("\t\t\t\n");
      out.write("\t\t}\n");
      out.write("\t\telse{\n");
      out.write("\t\t\tdocument.getElementById('div4').style.visibility=\"visible\";\n");
      out.write("\t\t\tdocument.myform.hchckall.value=0;\t\t\t\n");
      out.write("\t\t}\n");
      out.write("\t}\n");
      out.write("window.onload =Clear;\n");
      out.write("\n");
      out.write("function ChangeCriteria(str){\n");
      out.write("\tif(str == \"cust\"){\n");
      out.write("\t\tdocument.getElementById(\"myform\").style.display='block';\n");
      out.write("\t\tdocument.getElementById(\"myform1\").style.display='none';\n");
      out.write("\t}else if(str == \"order\"){\n");
      out.write("\t\tdocument.getElementById(\"myform\").style.display='none';\n");
      out.write("\t\tdocument.getElementById(\"myform1\").style.display='block';\n");
      out.write("\t\tdocument.getElementById(\"txtHint\").innerHTML=\"\";\n");
      out.write("\t\tdocument.getElementById(\"order_number\").focus();\n");
      out.write("\t\tdocument.getElementById(\"order_number\").value=\"\";\n");
      out.write("\t}\n");
      out.write("}\n");
      out.write("function isNumberKey(evt) {\n");
      out.write("\tvar charCode = (evt.which) ? evt.which : event.keyCode;\n");
      out.write("\tif (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57))\n");
      out.write("\t\treturn false;\n");
      out.write("\telse\n");
      out.write("\t\treturn true;\n");
      out.write("}\n");
      out.write("</script>\n");
      out.write(
          "\t<hr><center><div id=\"txtHint\" class=\"ddm1\" style=\"background-color: white;width: 100%;max-height: 400px;overflow: auto;\"></div></center>\n");
      out.write("\t<br><br>\n");
      out.write(
          "\t<p><h1><center><div id=\"waitMessage\"  style=\"cursor: sw-resize;\"></center></div></h1></p>\n");

      String fromFromName = "";
      if (request.getParameter("fromForm") != null) fromFromName = request.getParameter("fromForm");
      // CustPmtHstry

      out.write("\n");
      out.write("\t<input type=\"hidden\" name=\"fromForm\" value=\"");
      out.print(fromFromName);
      out.write("\">\n");
      out.write("</form>\n");
      out.write("\n");
      out.write(
          "<div id=\"dispdiv\" align=\"center\" style=\"border:1px solid black; padding:25px; text-align:center; display:none; background-color:#FFF; overflow:auto; height:300px; width=200px;\"> </div>\n");
      out.write("</body>\n");
      out.write("</html>\n");
    } catch (java.lang.Throwable t) {
      if (!(t instanceof javax.servlet.jsp.SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try {
            out.clearBuffer();
          } catch (java.io.IOException e) {
          }
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
        else throw new ServletException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    HttpSession session = request.getSession(true);

    try {
      Object accountObject = session.getValue(ACCOUNT);

      // If no account object was put in the session, or
      // if one exists but it is not a hashtable, then
      // redirect the user to the original login page

      if (accountObject == null)
        throw new RuntimeException("You need to log in to use this service!");

      if (!(accountObject instanceof Hashtable))
        throw new RuntimeException("You need to log in to use this service!");

      Hashtable account = (Hashtable) accountObject;

      String userName = (String) account.get("name");

      //////////////////////////////////////////////
      // Display Messages for the user who logged in
      //////////////////////////////////////////////
      out.println("<HTML>");
      out.println("<HEAD>");
      out.println("<TITLE>Contacts for " + userName + "</TITLE>");
      out.println("</HEAD>");
      out.println("<BODY BGCOLOR='#EFEFEF'>");
      out.println("<H3>Welcome " + userName + "</H3>");

      out.println("<CENTER>");

      Connection con = null;
      Statement stmt = null;
      ResultSet rs = null;
      try {
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        con =
            DriverManager.getConnection(
                "jdbc:mysql://localhost/contacts?user=kareena&password=kapoor");

        stmt = con.createStatement();
        rs =
            stmt.executeQuery(
                "SELECT * FROM contacts WHERE userName='******' ORDER BY contactID");

        out.println("<form name='deleteContactsForm' method='post' action='deleteContact'>");

        out.println("<TABLE BGCOLOR='#EFEFFF' CELLPADDING='2' CELLSPACING='4' BORDER='1'>");
        out.println("<TR BGCOLOR='#D6DFFF'>");
        out.println("<TD ALIGN='center'><B>Contact ID</B></TD>");
        out.println("<TD ALIGN='center'><B>Contact Name</B></TD>");
        out.println("<TD ALIGN='center'><B>Comment</B></TD>");
        out.println("<TD ALIGN='center'><B>Date</B></TD>");
        out.println("<TD ALIGN='center'><B>Delete Contacts</B></TD>");
        out.println("</TR>");

        int nRows = 0;
        while (rs.next()) {
          nRows++;
          String messageID = rs.getString("contactID");
          String fromUser = rs.getString("contactName");
          String message = rs.getString("comments");
          String messageDate = rs.getString("dateAdded");

          out.println("<TR>");
          out.println("<TD>" + messageID + "</TD>");
          out.println("<TD>" + fromUser + "</TD>");
          out.println("<TD>" + message + "</TD>");
          out.println("<TD>" + messageDate + "</TD>");
          out.println(
              "<TD><input type='checkbox' name='msgList' value='" + messageID + "'> Delete</TD>");
          out.println("</TR>");
        }

        out.println("<TR>");
        out.println(
            "<TD COLSPAN='6' ALIGN='center'><input type='submit' value='Delete Selected Contacts'></TD>");
        out.println("</TR>");

        out.println("</TABLE>");
        out.println("</FORM>");
      } catch (Exception e) {
        out.println("Could not connect to the users database.<P>");
        out.println("The error message was");
        out.println("<PRE>");
        out.println(e.getMessage());
        out.println("</PRE>");
      } finally {
        if (rs != null) {
          try {
            rs.close();
          } catch (SQLException ignore) {
          }
        }
        if (stmt != null) {
          try {
            stmt.close();
          } catch (SQLException ignore) {
          }
        }
        if (con != null) {
          try {
            con.close();
          } catch (SQLException ignore) {
          }
        }
      }

      out.println("</CENTER>");
      out.println("</BODY>");
      out.println("</HTML>");

    } catch (RuntimeException e) {
      out.println("<script language=\"javascript\">");
      out.println("alert(\"You need to log in to use this service!\");");
      out.println("</script>");

      out.println("<a href='index.html'>Click Here</a> to go to the main page.<br><br>");

      out.println(
          "Or Click on the button to exit<FORM><INPUT onClick=\"javascipt:window.close()\" TYPE=\"BUTTON\" VALUE=\"Close Browser\" TITLE=\"Click here to close window\" NAME=\"CloseWindow\" STYLE=\"font-family:Verdana, Arial, Helvetica; font-size:smaller; font-weight:bold\"></FORM>");

      log(e.getMessage());
      return;
    }
  }
  /** Business logic to execute. */
  public final Response executeCommand(
      Object inputPar,
      UserSessionParameters userSessionPars,
      HttpServletRequest request,
      HttpServletResponse response,
      HttpSession userSession,
      ServletContext context) {
    String serverLanguageId = ((JAIOUserSessionParameters) userSessionPars).getServerLanguageId();
    String username = ((JAIOUserSessionParameters) userSessionPars).getUsername();

    Connection conn = null;
    Statement stmt = null;
    try {
      conn = ConnectionManager.getConnection(context);

      // fires the GenericEvent.CONNECTION_CREATED event...
      EventsManager.getInstance()
          .processEvent(
              new GenericEvent(
                  this,
                  getRequestName(),
                  GenericEvent.CONNECTION_CREATED,
                  (JAIOUserSessionParameters) userSessionPars,
                  request,
                  response,
                  userSession,
                  context,
                  conn,
                  inputPar,
                  null));
      stmt = conn.createStatement();
      ResultSet rset =
          stmt.executeQuery(
              "select SYS04_ROLES.PROGRESSIVE,SYS04_ROLES.PROGRESSIVE_SYS10,SYS10_TRANSLATIONS.DESCRIPTION from "
                  + "SYS14_USER_ROLES,SYS04_ROLES,SYS10_TRANSLATIONS where "
                  + "SYS14_USER_ROLES.PROGRESSIVE_SYS04=SYS04_ROLES.PROGRESSIVE and "
                  + "SYS04_ROLES.PROGRESSIVE_SYS10=SYS10_TRANSLATIONS.PROGRESSIVE and "
                  + "SYS10_TRANSLATIONS.LANGUAGE_CODE='"
                  + serverLanguageId
                  + "' and "
                  + "SYS14_USER_ROLES.USERNAME_SYS03='"
                  + username
                  + "' and "
                  + "SYS04_ROLES.ENABLED='Y'");
      RoleVO vo = null;
      ArrayList list = new ArrayList();
      while (rset.next()) {
        vo = new RoleVO();
        vo.setDescriptionSYS10(rset.getString(3));
        vo.setEnabledSYS04("Y");
        vo.setProgressiveSYS04(rset.getBigDecimal(1));
        vo.setProgressiveSys10SYS04(rset.getBigDecimal(2));
        list.add(vo);
      }

      rset.close();
      Response answer = new VOListResponse(list, false, list.size());

      // fires the GenericEvent.BEFORE_COMMIT event...
      EventsManager.getInstance()
          .processEvent(
              new GenericEvent(
                  this,
                  getRequestName(),
                  GenericEvent.BEFORE_COMMIT,
                  (JAIOUserSessionParameters) userSessionPars,
                  request,
                  response,
                  userSession,
                  context,
                  conn,
                  inputPar,
                  answer));

      return answer;
    } catch (Throwable ex) {
      Logger.error(
          userSessionPars.getUsername(),
          this.getClass().getName(),
          "executeCommand",
          "Error while fetching user roles list",
          ex);
      return new ErrorResponse(ex.getMessage());
    } finally {
      try {
        stmt.close();
      } catch (Exception ex2) {
      }
      try {
        ConnectionManager.releaseConnection(conn, context);
      } catch (Exception ex1) {
      }
    }
  }