コード例 #1
0
ファイル: OperatorExists.java プロジェクト: rvbugs0/loyalty
  public void doGet(HttpServletRequest rq, HttpServletResponse rs) {
    PrintWriter pw = null;
    try {
      pw = rs.getWriter();
      rs.setContentType("application/json");
      OperatorBLInterface operatorInterface = new Operator();
      LoyaltyApplication loyaltyApplication = new LoyaltyApplication();
      boolean found = loyaltyApplication.operatorExists(Integer.parseInt(rq.getParameter("code")));

      pw.println("{");
      pw.println("\"success\":true,");
      pw.println("\"found\":" + found);

      pw.println("}");
    } catch (ApplicationException ae) {
      System.out.println(ae);

      pw.println("{");
      pw.println("\"success\":false,");
      pw.println("\"errorMessage\":" + "\"" + ae + "\"");
      pw.println("}");
    } catch (Exception e) {
      System.out.println(e);
    }
  }
コード例 #2
0
  public void doGet(HttpServletRequest rq, HttpServletResponse rs) {
    PrintWriter pw = null;
    try {
      pw = rs.getWriter();
      rs.setContentType("application/json");
      LoyaltyApplication loyaltyApplication = new LoyaltyApplication();
      loyaltyApplication.removeOperator(Integer.parseInt(rq.getParameter("code")));
      pw.println("{");
      pw.println("\"success\":true,");
      pw.println("\"message\":\"removed\"");
      pw.println("}");

    } catch (ApplicationException ae) {

      System.out.println(ae);

      pw.println("{");
      pw.println("\"success\":false,");
      pw.println("\"errorMessage\":" + "\"" + ae + "\"");
      pw.println("}");

    } catch (IOException ioe) {
      System.out.println(ioe);
    }
  }