コード例 #1
0
  /**
   * Gathers the parameters in the request as a HTTP URL string. to form request parameters and
   * policy advice String array. It collects all the parameters from the original request except the
   * original goto url and any advice parameters. Note: All the paramters will be url decoded by
   * default., we should make sure that these values are encoded again
   *
   * @param request an HttpServletRequest object that contains the request the client has made of
   *     the servlet.
   * @return An String array, index 0 is policy advice, index 1 is rest of the request parameters
   */
  private String[] parseRequestParams(HttpServletRequest request) {
    StringBuilder adviceList = null;
    StringBuilder parameterString = new StringBuilder(100);
    for (Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) {
      String paramName = (String) e.nextElement();
      if (adviceParams.contains(paramName.toLowerCase())) {
        if (adviceList == null) {
          adviceList = new StringBuilder();
        } else {
          adviceList.append(AMPERSAND);
        }
        String[] values = request.getParameterValues(paramName);
        for (int i = 0; values != null && i < values.length; i++) {
          adviceList.append(paramName).append(EQUAL_TO).append(values[i]);
        }
      } else {
        if (!paramName.equals(GOTO_PARAMETER)) {
          String[] values = request.getParameterValues(paramName);
          for (int i = 0; values != null && i < values.length; i++) {
            parameterString
                .append(AMPERSAND)
                .append(paramName)
                .append(EQUAL_TO)
                .append(URLEncDec.encode(values[i]));
          }
        }
      }
    }
    if (debug.messageEnabled()) {
      debug.message("CDCClientServlet.parseRequestParams:" + "Advice List is = " + adviceList);
      debug.message(
          "CDCClientServlet.parseRequestParams:"
              + "Parameter String is = "
              + parameterString.toString());
    }

    String policyAdviceList;
    String requestParams;

    if (adviceList == null) {
      policyAdviceList = null;
    } else {
      policyAdviceList = adviceList.toString();
    }

    if (parameterString.length() > 0) {
      requestParams = (parameterString.deleteCharAt(0).toString());
    } else {
      requestParams = parameterString.toString();
    }

    return new String[] {policyAdviceList, requestParams};
  }
コード例 #2
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Reading All Request Parameters";
    out.println(
        ServletUtilities.headWithTitle(title)
            + "<BODY BGCOLOR=\"#FDF5E6\">\n"
            + "<H1 ALIGN=CENTER>"
            + title
            + "</H1>\n"
            + "<TABLE BORDER=1 ALIGN=CENTER>\n"
            + "<TR BGCOLOR=\"#FFAD00\">\n"
            + "<TH>Parameter Name<TH>Parameter Value(s)");
    Enumeration paramNames = request.getParameterNames();
    while (paramNames.hasMoreElements()) {
      String paramName = (String) paramNames.nextElement();
      out.println("<TR><TD>" + paramName + "\n<TD>");
      String[] paramValues = request.getParameterValues(paramName);
      if (paramValues.length == 1) {
        String paramValue = paramValues[0];
        if (paramValue.length() == 0) out.print("<I>No Value</I>");
        else out.print(paramValue);
      } else {
        out.println("<UL>");
        for (int i = 0; i < paramValues.length; i++) {
          out.println("<LI>" + paramValues[i]);
        }
        out.println("</UL>");
      }
    }
    out.println("</TABLE>\n</BODY></HTML>");
  }
コード例 #3
0
ファイル: doRoles.java プロジェクト: weatchley/classic-java
 private void getPermissions(HttpServletRequest request, Role item) {
   String[] per = request.getParameterValues("permissions");
   item.clearPermissions();
   for (int i = 0; i < per.length; i++) {
     item.addPermission(Long.parseLong(per[i]));
   }
 }
コード例 #4
0
ファイル: doRoles.java プロジェクト: weatchley/classic-java
 private void getPositions(HttpServletRequest request, Role item) {
   String[] pos = request.getParameterValues("positions");
   item.clearPositions();
   for (int i = 0; i < pos.length; i++) {
     item.addPosition(Long.parseLong(pos[i]));
   }
 }
コード例 #5
0
 /**
  * Return the values of the given parameter (ignoring case) for the given request.
  *
  * @param req the HttpServletRequest
  * @param paramName the name of the parameter to find.
  * @return the values of the given parameter for the given request.
  */
 public static String[] getParameterValuesIgnoreCase(HttpServletRequest req, String paramName) {
   Enumeration e = req.getParameterNames();
   while (e.hasMoreElements()) {
     String s = (String) e.nextElement();
     if (s.equalsIgnoreCase(paramName)) return req.getParameterValues(s);
   }
   return null;
 }
コード例 #6
0
  /**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();

    LookupService lookupService = new LookupService();
    coshms.ejb.pathalogy.PathalogyRemote pthRemoteSB = lookupService.lookupPathalogyBean();

    java.util.ArrayList pthTestDomainList = new java.util.ArrayList();
    int tStatus = 0;

    if (request.getParameter("status") != null) {
      tStatus = 1;
    }
    String[] cid = request.getParameterValues("contentId");
    String[] cname = request.getParameterValues("cname");
    String[] unit = request.getParameterValues("unit");
    String[] minvalue = request.getParameterValues("minvalue");
    String[] maxvalue = request.getParameterValues("maxvalue");

    for (int i = 0; i < cname.length; i++) {
      PthTestContentsInfo pthTestCon =
          new PthTestContentsInfo(
              "",
              Integer.parseInt(cid[i]),
              cname[i],
              Double.parseDouble(minvalue[i]),
              Double.parseDouble(maxvalue[i]),
              unit[i]);
      pthTestDomainList.add(pthTestCon);
    }
    int empId = 1;

    if (pthRemoteSB.pthTestDomainEdit(
        pthTestDomainList,
        request.getParameter("tname"),
        tStatus,
        Integer.parseInt(request.getParameter("tcost")),
        empId,
        Integer.parseInt(request.getParameter("testId"))))
      response.sendRedirect("pthMessage.jsp?message=Pathalogy Test Edit Successfully");
    else response.sendRedirect("pthMessage.jsp?message=Try Again");
    out.close();
  }
コード例 #7
0
ファイル: MyServlet.java プロジェクト: odedns/oded-repo
  /** @service the servlet service request. called once for each servlet request. */
  public void service(HttpServletRequest servReq, HttpServletResponse servRes) throws IOException {
    String name;
    String value[];
    String val;

    servRes.setHeader("AUTHORIZATION", "user fred:mypassword");
    ServletOutputStream out = servRes.getOutputStream();

    HttpSession session = servReq.getSession(true);
    session.setAttribute("timemilis", new Long(System.currentTimeMillis()));
    if (session.isNew()) {
      out.println("<p> Session is new ");
    } else {
      out.println("<p> Session is not new ");
    }
    Long l = (Long) session.getAttribute("timemilis");
    out.println("<p> Session id = " + session.getId());
    out.println("<p> TimeMillis = " + l);

    out.println("<H2>Servlet Params</H2>");
    Enumeration e = servReq.getParameterNames();
    while (e.hasMoreElements()) {
      name = (String) e.nextElement();
      value = servReq.getParameterValues(name);
      out.println(name + " : ");
      for (int i = 0; i < value.length; ++i) {
        out.println(value[i]);
      }
      out.println("<p>");
    }

    out.println("<H2> Request Headers : </H2>");
    e = servReq.getHeaderNames();
    while (e.hasMoreElements()) {
      name = (String) e.nextElement();
      val = (String) servReq.getHeader(name);
      out.println("<p>" + name + " : " + val);
    }
    try {
      BufferedReader br = servReq.getReader();
      String line = null;
      while (null != (line = br.readLine())) {
        out.println(line);
      }
    } catch (IOException ie) {
      ie.printStackTrace();
    }

    session.invalidate();
  }
コード例 #8
0
 protected void logParams() {
   Enumeration en = req.getParameterNames();
   while (en.hasMoreElements()) {
     String name = (String) en.nextElement();
     String vals[];
     String dispval;
     if (StringUtil.indexOfIgnoreCase(name, "passw") >= 0) {
       dispval = req.getParameter(name).length() == 0 ? "" : "********";
     } else if (log.isDebug2() && (vals = req.getParameterValues(name)).length > 1) {
       dispval = StringUtil.separatedString(vals, ", ");
     } else {
       dispval = req.getParameter(name);
     }
     log.debug(name + " = " + dispval);
   }
 }
コード例 #9
0
 // Get parameter map either directly from an Servlet 2.4 compliant implementation
 // or by looking it up explictely (thanks to codewax for the patch)
 private Map<String, String[]> getParameterMap(HttpServletRequest pReq) {
   try {
     // Servlet 2.4 API
     return pReq.getParameterMap();
   } catch (UnsupportedOperationException exp) {
     // Thrown by 'pseudo' 2.4 Servlet API implementations which fake a 2.4 API
     // As a service for the parameter map is build up explicitely
     Map<String, String[]> ret = new HashMap<String, String[]>();
     Enumeration params = pReq.getParameterNames();
     while (params.hasMoreElements()) {
       String param = (String) params.nextElement();
       ret.put(param, pReq.getParameterValues(param));
     }
     return ret;
   }
 }
コード例 #10
0
ファイル: ShoppingCart.java プロジェクト: chenyuguxing/utils
  public void doPost(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {

    // 取得Session对象
    // 如果Session不存在,为本次会话创建此对象
    HttpSession session = req.getSession(true);
    Integer itemCount = (Integer) session.getValue("itemCount");
    // 如果session是新的
    if (itemCount == null) itemCount = new Integer(0);

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

    // 接收传来的参数
    String[] itemsSelected;
    String itemName;
    itemsSelected = req.getParameterValues("item");

    if (itemsSelected != null) {
      for (int i = 0; i < itemsSelected.length; i++) {
        itemName = itemsSelected[i];
        System.out.println(itemName);
        itemCount = new Integer(itemCount.intValue() + 1);
        // 购买的条目
        session.putValue("item" + itemCount, itemName);
        // 总条目
        session.putValue("itemCount", itemCount);
      }
    }

    out.println("<html>");
    out.println("<title>");
    out.println("item list");
    out.println("</title>");
    out.println("<body><h4>Session List:</h4><hr><br><br>");
    for (int i = 1; i <= itemCount.intValue(); i++) {
      out.println((String) session.getValue("item" + i) + "<hr>");
    }
    out.println("</body>");
    out.println("</html>");
    out.close();
  }
コード例 #11
0
ファイル: Servlet.java プロジェクト: dwiel/axpress-nlp
  protected Request setupRequest(String serviceURI, HttpServletRequest httpRequest, String opType)
      throws IOException {
    // No reader.  Done by standard servlet form processing.
    Request request = new Request(serviceURI, null);
    // params => request items
    @SuppressWarnings("unchecked")
    Enumeration<String> en = httpRequest.getParameterNames();

    for (; en.hasMoreElements(); ) {
      String k = en.nextElement();
      String[] x = httpRequest.getParameterValues(k);

      for (int i = 0; i < x.length; i++) {
        String s = x[i];
        request.setParam(k, s);
      }
    }
    request.setParam(Joseki.OPERATION, opType);
    return request;
  }
コード例 #12
0
ファイル: SaveName_jsp.java プロジェクト: waijie666/pbss
  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("\n");
      out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n");
      out.write("   \"http://www.w3.org/TR/html4/loose.dtd\">\n");
      out.write("\n");
      out.write("<html>\n");
      out.write("<body>\n");
      out.write('\n');
      out.write('\n');

      PrintWriter write =
          new PrintWriter(
              new BufferedWriter(new FileWriter((getServletContext().getRealPath("/output.csv")))));
      int i;
      String[] NoofBusstop = request.getParameterValues("NoofbusStop");
      String[] routeID = request.getParameterValues("routeID");
      String[] routeInterval = request.getParameterValues("routeInterval");
      String[] busStopID = request.getParameterValues("busStopID");
      String[] busStopName = request.getParameterValues("busStopName");
      String[] busStopDescription = request.getParameterValues("busStopDescription");
      String[] busStopOrder = request.getParameterValues("busStopOrder");
      String[] busStopStatus = request.getParameterValues("busStopStatus");
      String[] busStopPeopleNum = request.getParameterValues("busStopPeopleNum");

      int a = 0;
      int b = 0;
      int count = 0;
      int NoofBusstops = 0;
      out.println(
          "\"routeID\",\"routeInterval \",\"busStopID\",\"busStopName\",\"busStopDescription\",\"busStopOrder\",\"busStopStatus\",\"busStopPeopleNum\"");
      write.println(
          "\"routeID\",\"routeInterval \",\"busStopID\",\"busStopName\",\"busStopDescription\",\"busStopOrder\",\"busStopStatus\",\"busStopPeopleNum\"");

      out.println("<BR>");
      for (i = 0; i < busStopID.length; i++) {

        NoofBusstops = Integer.parseInt(NoofBusstop[b]);
        count++;
        if (count > NoofBusstops) {
          a++;
          b++;
          count = 1;
        }

        out.println(
            routeID[a]
                + ","
                + routeInterval[a]
                + ","
                + busStopID[i]
                + ",\""
                + busStopName[i]
                + "\",\""
                + busStopDescription[i]
                + "\","
                + busStopOrder[i]
                + ","
                + busStopStatus[i]
                + ","
                + busStopPeopleNum[i]
                + "<BR>");

        write.println(
            routeID[a]
                + ","
                + routeInterval[a]
                + ","
                + busStopID[i]
                + ",\""
                + busStopName[i]
                + "\",\""
                + busStopDescription[i]
                + "\","
                + busStopOrder[i]
                + ","
                + busStopStatus[i]
                + ","
                + busStopPeopleNum[i]);
      }

      write.close();

      /*
      out.println(request.getParameter("routeInterval")+"<BR>");
      out.println(request.getParameter("busStopID")+"<BR>");
      out.println(request.getParameter("busStopName")+"<BR>");
      out.println(request.getParameter("busStopDescription")+"<BR>");
      out.println(request.getParameter("busStopOrder")+"<BR>");
      out.println(request.getParameter("busStopStatus")+"<BR>");
      out.println(request.getParameter("busStopPeopleNum")+"<BR>");
      */

      out.write("\n");
      out.write("\n");
      out.write("</body>\n");
      out.write("</html>");
    } 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);
    }
  }
コード例 #13
0
ファイル: credit_check_ok.java プロジェクト: RainerJava/erp-6
  public synchronized void doPost(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    HttpSession dbSession = request.getSession();
    JspFactory _jspxFactory = JspFactory.getDefaultFactory();
    PageContext pageContext =
        _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
    ServletContext dbApplication = dbSession.getServletContext();

    try {
      PrintWriter out = response.getWriter();

      nseer_db_backup1 stock_db = new nseer_db_backup1(dbApplication);
      nseer_db_backup1 crm_db = new nseer_db_backup1(dbApplication);
      if (stock_db.conn((String) dbSession.getAttribute("unit_db_name"))
          && crm_db.conn((String) dbSession.getAttribute("unit_db_name"))) {

        FileKind FileKind = new FileKind();
        ValidataNumber validata = new ValidataNumber();
        ValidataRecord vr = new ValidataRecord();

        counter count = new counter(dbApplication);
        ValidataTag vt = new ValidataTag();
        String register_ID = (String) dbSession.getAttribute("human_IDD");
        String config_id = request.getParameter("config_id");
        String pay_ID = request.getParameter("pay_ID");
        String product_amount = request.getParameter("product_amount");
        int num = Integer.parseInt(product_amount);
        String payer_name = request.getParameter("payer_name");
        String payer_ID = request.getParameter("payer_ID");
        String reason = request.getParameter("reason");
        String not_return_tag = request.getParameter("not_return_tag");
        String register = request.getParameter("register");
        String register_time = request.getParameter("register_time");
        String demand_return_time = request.getParameter("demand_return_time");
        String sales_name = request.getParameter("sales_name");
        String sales_ID = request.getParameter("sales_ID");
        String bodyc = new String(request.getParameter("remark").getBytes("UTF-8"), "UTF-8");
        String remark = exchange.toHtml(bodyc);
        String time = "";
        java.util.Date now = new java.util.Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
        time = formatter.format(now);
        String[] product_IDn = request.getParameterValues("product_ID");
        String[] amountn = request.getParameterValues("amount");
        if (num == 0 && product_IDn.length == 1) {
          response.sendRedirect("draft/crm/credit_ok_a.jsp?pay_ID=" + pay_ID);
        } else {
          int p = 0;
          for (int i = 1; i <= num; i++) {
            String tem_amount = "amount" + i;
            String amount = request.getParameter(tem_amount);
            if (amount.equals("")) amount = "0";
            if (!validata.validata(amount)) {
              p++;
            }
          }
          int n = 0;
          String product_ID_group = "";
          for (int j = 1; j < product_IDn.length; j++) {
            product_ID_group += product_IDn[j] + ",";
            if (amountn[j].equals("")) amountn[j] = "0";
            if (!validata.validata(amountn[j])) {
              p++;
            }
          }
          for (int i = 1; i <= num; i++) {
            String tem_product_ID = "product_ID" + i;
            String product_ID = request.getParameter(tem_product_ID);
            if (product_ID_group.indexOf(product_ID) != -1) n++;
          }
          if (vt.validata(
                      (String) dbSession.getAttribute("unit_db_name"),
                      "stock_apply_pay",
                      "pay_ID",
                      pay_ID,
                      "check_tag")
                  .equals("9")
              || vt.validata(
                      (String) dbSession.getAttribute("unit_db_name"),
                      "stock_apply_pay",
                      "pay_ID",
                      pay_ID,
                      "check_tag")
                  .equals("5")) {

            if (p == 0) {
              try {
                if (n == 0) {
                  boolean flag = false;
                  List rsList = GetWorkflow.getList(crm_db, "crm_config_workflow", "05");
                  String[] elem = new String[3];
                  if (rsList.size() == 0) {
                    flag = true;
                  }
                  String sqll = "";
                  String[] aaa1 =
                      FileKind.getKind(
                          (String) dbSession.getAttribute("unit_db_name"),
                          "crm_file",
                          "customer_ID",
                          payer_ID);

                  String stock_pay_ID =
                      NseerId.getId("stock/pay", (String) dbSession.getAttribute("unit_db_name"));
                  double demand_amount = 0.0d;
                  double list_price_sum = 0.0d;
                  double cost_price_sum = 0.0d;

                  for (int i = 1; i <= num; i++) {
                    String tem_product_name = "product_name" + i;
                    String tem_product_ID = "product_ID" + i;
                    String tem_available_amount = "available_amount" + i;
                    String tem_amount = "amount" + i;
                    String tem_list_price = "list_price" + i;
                    String tem_cost_price = "cost_price" + i;
                    String tem_type = "type" + i;
                    String tem_amount_unit = "amount_unit" + i;
                    String product_name = request.getParameter(tem_product_name);
                    String product_ID = request.getParameter(tem_product_ID);
                    String available_amount = request.getParameter(tem_available_amount);
                    String amount = request.getParameter(tem_amount);
                    if (amount.equals("")) amount = "0";
                    String list_price2 = request.getParameter(tem_list_price);
                    String cost_price = request.getParameter(tem_cost_price);
                    String type = request.getParameter(tem_type);
                    StringTokenizer tokenTO3 = new StringTokenizer(list_price2, ",");
                    String list_price = "";
                    while (tokenTO3.hasMoreTokens()) {
                      String list_price1 = tokenTO3.nextToken();
                      list_price += list_price1;
                    }
                    String amount_unit = request.getParameter(tem_amount_unit);
                    double list_price_subtotal =
                        Double.parseDouble(list_price) * Double.parseDouble(amount);
                    list_price_sum += list_price_subtotal;
                    double cost_price_subtotal =
                        Double.parseDouble(cost_price) * Double.parseDouble(amount);
                    cost_price_sum += cost_price_subtotal;
                    demand_amount += Double.parseDouble(amount);
                    String sql1 =
                        "update stock_apply_pay_details set amount='"
                            + amount
                            + "',list_price='"
                            + list_price
                            + "',list_price_subtotal='"
                            + list_price_subtotal
                            + "',cost_price='"
                            + cost_price
                            + "',subtotal='"
                            + cost_price_subtotal
                            + "' where pay_ID='"
                            + pay_ID
                            + "' and details_number='"
                            + i
                            + "'";
                    stock_db.executeUpdate(sql1);
                    if (flag) {
                      if (type.equals("物料") || type.equals("外购商品")) {
                        String sql2 =
                            "insert into stock_pay_details(pay_ID,details_number,product_ID,product_name,type,list_price,list_price_subtotal,cost_price,subtotal,amount,unpay_amount,apply_manufacture_amount,apply_purchase_amount) values('"
                                + stock_pay_ID
                                + "','"
                                + i
                                + "','"
                                + product_ID
                                + "','"
                                + product_name
                                + "','"
                                + type
                                + "','"
                                + list_price
                                + "','"
                                + list_price_subtotal
                                + "','"
                                + cost_price
                                + "','"
                                + cost_price_subtotal
                                + "','"
                                + amount
                                + "','"
                                + amount
                                + "','0','"
                                + amount
                                + "')";
                        stock_db.executeUpdate(sql2);
                      } else if (type.equals("商品") || type.equals("部件") || type.equals("委外部件")) {
                        String sql2 =
                            "insert into stock_pay_details(pay_ID,details_number,product_ID,product_name,type,list_price,list_price_subtotal,cost_price,subtotal,amount,unpay_amount,apply_manufacture_amount,apply_purchase_amount) values('"
                                + stock_pay_ID
                                + "','"
                                + i
                                + "','"
                                + product_ID
                                + "','"
                                + product_name
                                + "','"
                                + type
                                + "','"
                                + list_price
                                + "','"
                                + list_price_subtotal
                                + "','"
                                + cost_price
                                + "','"
                                + cost_price_subtotal
                                + "','"
                                + amount
                                + "','"
                                + amount
                                + "','"
                                + amount
                                + "','0')";
                        stock_db.executeUpdate(sql2);
                      }

                      String sql97 =
                          "select * from crm_salecredit_balance_details where crediter_ID='"
                              + payer_ID
                              + "' and product_ID='"
                              + product_ID
                              + "'";
                      ResultSet rs97 = crm_db.executeQuery(sql97);
                      if (rs97.next()) {
                        double balance_amount =
                            rs97.getDouble("amount") + Double.parseDouble(amount);
                        double balance_cost_price_subtotal =
                            rs97.getDouble("subtotal") + cost_price_subtotal;
                        double balance_list_price_subtotal =
                            rs97.getDouble("list_price_subtotal") + list_price_subtotal;

                        String sql96 =
                            "update crm_salecredit_balance_details set amount='"
                                + balance_amount
                                + "',check_tag='1',subtotal='"
                                + balance_cost_price_subtotal
                                + "',list_price_subtotal='"
                                + balance_list_price_subtotal
                                + "' where crediter_ID='"
                                + payer_ID
                                + "' and product_ID='"
                                + product_ID
                                + "'";
                        crm_db.executeUpdate(sql96);
                      } else {
                        String[] aaa =
                            FileKind.getKind(
                                (String) dbSession.getAttribute("unit_db_name"),
                                "design_file",
                                "product_ID",
                                product_ID);
                        String sql95 =
                            "insert into crm_salecredit_balance_details(chain_ID,chain_name,crediter_chain_ID,crediter_chain_name,product_ID,product_name,list_price,list_price_subtotal,cost_price,subtotal,amount,crediter_ID,crediter_name) values('"
                                + aaa[0]
                                + "','"
                                + aaa[1]
                                + "','"
                                + aaa1[0]
                                + "','"
                                + aaa1[1]
                                + "','"
                                + product_ID
                                + "','"
                                + product_name
                                + "','"
                                + list_price
                                + "','"
                                + list_price_subtotal
                                + "','"
                                + cost_price
                                + "','"
                                + cost_price_subtotal
                                + "','"
                                + amount
                                + "','"
                                + payer_ID
                                + "','"
                                + payer_name
                                + "')";
                        crm_db.executeUpdate(sql95);
                      }
                    }
                  }
                  String[] cost_pricen = request.getParameterValues("cost_price");
                  String[] list_pricen = request.getParameterValues("list_price");
                  String[] product_namen = request.getParameterValues("product_name");
                  String[] product_describen = request.getParameterValues("product_describe");
                  String[] amount_unitn = request.getParameterValues("amount_unit");
                  String[] typen = request.getParameterValues("type");
                  for (int i = 1; i < product_IDn.length; i++) {
                    StringTokenizer tokenTO3 = new StringTokenizer(list_pricen[i], ",");
                    String list_price = "";
                    while (tokenTO3.hasMoreTokens()) {
                      String list_price1 = tokenTO3.nextToken();
                      list_price += list_price1;
                    }
                    if (!amountn[i].equals("") && Double.parseDouble(amountn[i]) != 0) {
                      double list_price_subtotal =
                          Double.parseDouble(list_price) * Double.parseDouble(amountn[i]);
                      list_price_sum += list_price_subtotal;
                      double subtotal =
                          Double.parseDouble(cost_pricen[i]) * Double.parseDouble(amountn[i]);
                      cost_price_sum += subtotal;
                      demand_amount += Double.parseDouble(amountn[i]);
                      num++;
                      String sql1 =
                          "insert into stock_apply_pay_details(payer_chain_ID,payer_chain_name,sales_ID,sales_name,payer_ID,payer_name,payer_type,pay_ID,details_number,product_ID,product_name,product_describe,amount,amount_unit,list_price,list_price_subtotal,cost_price,subtotal,type) values ('"
                              + aaa1[0]
                              + "','"
                              + aaa1[1]
                              + "','"
                              + sales_ID
                              + "','"
                              + sales_name
                              + "','"
                              + payer_ID
                              + "','"
                              + payer_name
                              + "','销售赊货','"
                              + pay_ID
                              + "','"
                              + num
                              + "','"
                              + product_IDn[i]
                              + "','"
                              + product_namen[i]
                              + "','"
                              + product_describen[i]
                              + "','"
                              + amountn[i]
                              + "','"
                              + amount_unitn[i]
                              + "','"
                              + list_price
                              + "','"
                              + list_price_subtotal
                              + "','"
                              + cost_pricen[i]
                              + "','"
                              + subtotal
                              + "','"
                              + typen[i]
                              + "')";
                      stock_db.executeUpdate(sql1);
                      // **********************
                      if (rsList.size() == 0) {
                        if (typen[i].equals("物料") || typen[i].equals("外购商品")) {
                          String sql2 =
                              "insert into stock_pay_details(pay_ID,details_number,product_ID,product_name,type,list_price,list_price_subtotal,cost_price,subtotal,amount,unpay_amount,apply_manufacture_amount,apply_purchase_amount) values('"
                                  + stock_pay_ID
                                  + "','"
                                  + num
                                  + "','"
                                  + product_IDn[i]
                                  + "','"
                                  + product_namen[i]
                                  + "','"
                                  + typen[i]
                                  + "','"
                                  + list_price
                                  + "','"
                                  + list_price_subtotal
                                  + "','"
                                  + cost_pricen[i]
                                  + "','"
                                  + subtotal
                                  + "','"
                                  + amountn[i]
                                  + "','"
                                  + amountn[i]
                                  + "','0','"
                                  + amountn[i]
                                  + "')";
                          stock_db.executeUpdate(sql2);
                        } else if (typen[i].equals("商品")
                            || typen[i].equals("部件")
                            || typen[i].equals("委外部件")) {
                          String sql2 =
                              "insert into stock_pay_details(pay_ID,details_number,product_ID,product_name,type,list_price,list_price_subtotal,cost_price,subtotal,amount,unpay_amount,apply_manufacture_amount,apply_purchase_amount) values('"
                                  + stock_pay_ID
                                  + "','"
                                  + num
                                  + "','"
                                  + product_IDn[i]
                                  + "','"
                                  + product_namen[i]
                                  + "','"
                                  + typen[i]
                                  + "','"
                                  + list_price
                                  + "','"
                                  + list_price_subtotal
                                  + "','"
                                  + cost_pricen[i]
                                  + "','"
                                  + subtotal
                                  + "','"
                                  + amountn[i]
                                  + "','"
                                  + amountn[i]
                                  + "','"
                                  + amountn[i]
                                  + "','0')";
                          stock_db.executeUpdate(sql2);
                        }

                        String sql97 =
                            "select * from crm_salecredit_balance_details where crediter_ID='"
                                + payer_ID
                                + "' and product_ID='"
                                + product_IDn[i]
                                + "'";
                        ResultSet rs97 = crm_db.executeQuery(sql97);
                        if (rs97.next()) {
                          double balance_amount =
                              rs97.getDouble("amount") + Double.parseDouble(amountn[i]);
                          double balance_cost_price_subtotal =
                              rs97.getDouble("subtotal") + subtotal;
                          double balance_list_price_subtotal =
                              rs97.getDouble("list_price_subtotal") + list_price_subtotal;

                          String sql96 =
                              "update crm_salecredit_balance_details set amount='"
                                  + balance_amount
                                  + "',check_tag='1',subtotal='"
                                  + balance_cost_price_subtotal
                                  + "',list_price_subtotal='"
                                  + balance_list_price_subtotal
                                  + "' where crediter_ID='"
                                  + payer_ID
                                  + "' and product_ID='"
                                  + product_IDn[i]
                                  + "'";
                          crm_db.executeUpdate(sql96);
                        } else {
                          String[] aaa =
                              FileKind.getKind(
                                  (String) dbSession.getAttribute("unit_db_name"),
                                  "design_file",
                                  "product_ID",
                                  product_IDn[i]);
                          String sql95 =
                              "insert into crm_salecredit_balance_details(chain_ID,chain_name,crediter_chain_ID,crediter_chain_name,product_ID,product_name,list_price,list_price_subtotal,cost_price,subtotal,amount,crediter_ID,crediter_name) values('"
                                  + aaa[0]
                                  + "','"
                                  + aaa[1]
                                  + "','"
                                  + aaa1[0]
                                  + "','"
                                  + aaa1[1]
                                  + "','"
                                  + product_IDn[i]
                                  + "','"
                                  + product_namen[i]
                                  + "','"
                                  + list_price
                                  + "','"
                                  + list_price_subtotal
                                  + "','"
                                  + cost_pricen[i]
                                  + "','"
                                  + subtotal
                                  + "','"
                                  + amountn[i]
                                  + "','"
                                  + payer_ID
                                  + "','"
                                  + payer_name
                                  + "')";
                          crm_db.executeUpdate(sql95);
                        }
                      }
                      // ***************************
                    }
                  }
                  String sql =
                      "update stock_apply_pay set reason='"
                          + reason
                          + "',register='"
                          + register
                          + "',register_time='"
                          + register_time
                          + "',demand_return_time='"
                          + demand_return_time
                          + "',register_time='"
                          + register_time
                          + "',register='"
                          + register
                          + "',remark='"
                          + remark
                          + "',demand_amount='"
                          + demand_amount
                          + "',list_price_sum='"
                          + list_price_sum
                          + "',cost_price_sum='"
                          + cost_price_sum
                          + "',not_return_tag='"
                          + not_return_tag
                          + "' where pay_ID='"
                          + pay_ID
                          + "'";
                  stock_db.executeUpdate(sql);
                  if (flag) {
                    sql = "update stock_apply_pay set check_tag='1' where pay_ID='" + pay_ID + "'";
                    stock_db.executeUpdate(sql);
                    if (!vr.validata(
                        (String) dbSession.getAttribute("unit_db_name"),
                        "stock_pay",
                        "reasonexact",
                        pay_ID)) {
                      String sql4 =
                          "insert into stock_pay(pay_ID,reason,reasonexact,reasonexact_details,demand_amount,list_price_sum,cost_price_sum,register,register_time) values('"
                              + stock_pay_ID
                              + "','"
                              + reason
                              + "','"
                              + pay_ID
                              + "','"
                              + payer_name
                              + "','"
                              + demand_amount
                              + "','"
                              + list_price_sum
                              + "','"
                              + cost_price_sum
                              + "','"
                              + register
                              + "','"
                              + register_time
                              + "')";
                      stock_db.executeUpdate(sql4);
                    }

                    String sql98 = "select * from crm_file where customer_ID='" + payer_ID + "'";
                    ResultSet rs98 = crm_db.executeQuery(sql98);
                    if (rs98.next()) {
                      double salecredit_list_price_sum =
                          rs98.getDouble("salecredit_list_price_sum") + list_price_sum;
                      double salecredit_cost_price_sum =
                          rs98.getDouble("salecredit_cost_price_sum") + cost_price_sum;

                      String sql99 =
                          "update crm_file set credit_yes_or_not_tag='1',salecredit_list_price_sum='"
                              + salecredit_list_price_sum
                              + "',salecredit_cost_price_sum='"
                              + salecredit_cost_price_sum
                              + "' where customer_ID='"
                              + payer_ID
                              + "' ";
                      crm_db.executeUpdate(sql99);
                    }
                  } else {
                    sql = "update stock_apply_pay set check_tag='0' where pay_ID='" + pay_ID + "'";
                    stock_db.executeUpdate(sql);
                    Iterator ite = rsList.iterator();
                    while (ite.hasNext()) {
                      elem = (String[]) ite.next();
                      sql =
                          "insert into crm_workflow(config_id,object_ID,describe1,describe2) values ('"
                              + elem[0]
                              + "','"
                              + pay_ID
                              + "','"
                              + elem[1]
                              + "','"
                              + elem[2]
                              + "')";
                      crm_db.executeUpdate(sql);
                    }
                  }

                  response.sendRedirect("draft/crm/credit_ok.jsp?finished_tag=8");
                } else {

                  response.sendRedirect(
                      "draft/crm/credit_ok.jsp?finished_tag=7&pay_ID=" + pay_ID + "");
                }
              } catch (Exception ex) {
                ex.printStackTrace();
              }
            } else {

              response.sendRedirect("draft/crm/credit_ok.jsp?finished_tag=6&pay_ID=" + pay_ID + "");
            }
          } else {

            response.sendRedirect("draft/crm/credit_ok.jsp?finished_tag=9");
          }
        }
        stock_db.commit();
        crm_db.commit();
        stock_db.close();
        crm_db.close();
      } else {
        response.sendRedirect("error_conn.htm");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
コード例 #14
0
  public synchronized void service(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    HttpSession dbSession = request.getSession();
    JspFactory _jspxFactory = JspFactory.getDefaultFactory();
    PageContext pageContext =
        _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
    ServletContext dbApplication = dbSession.getServletContext();
    try {
      HttpSession session = request.getSession();
      PrintWriter out = response.getWriter();
      nseer_db_backup1 fund_db = new nseer_db_backup1(dbApplication);
      nseer_db_backup1 fund_db1 = new nseer_db_backup1(dbApplication);
      if (fund_db.conn((String) dbSession.getAttribute("unit_db_name"))
          && fund_db1.conn((String) dbSession.getAttribute("unit_db_name"))) {
        counter count = new counter(dbApplication);
        ValidataRecordNumber vrn = new ValidataRecordNumber();
        ValidataTag vt = new ValidataTag();
        ValidataNumber validata = new ValidataNumber();
        try {
          String time = "";
          java.util.Date now = new java.util.Date();
          SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
          time = formatter.format(now);

          String apply_pay_ID = request.getParameter("apply_pay_ID");
          String register_time = request.getParameter("register_time");
          String register = request.getParameter("register");
          String register_ID = request.getParameter("register_ID");
          String bodyc = new String(request.getParameter("remark").getBytes("UTF-8"), "UTF-8");
          String remark = exchange.toHtml(bodyc);
          String amount = request.getParameter("amount");
          String[] file_kind = request.getParameterValues("file_kind");
          String[] cost_price_subtotal = request.getParameterValues("cost_price_subtotal");
          int p = 0;
          String file_kinda = ",";
          for (int j = 1; j < file_kind.length; j++) {
            file_kinda += file_kind[j] + ",";
            if (cost_price_subtotal[j].equals("")) cost_price_subtotal[j] = "0";
            StringTokenizer tokenTO4 = new StringTokenizer(cost_price_subtotal[j], ",");
            String cost_price_subtotal1 = "";
            while (tokenTO4.hasMoreTokens()) {
              cost_price_subtotal1 += tokenTO4.nextToken();
            }
            if (!validata.validata(cost_price_subtotal1)) {
              p++;
            }
          }
          int n = 0;
          for (int i = 1; i <= Integer.parseInt(amount); i++) {
            String tem_file_kind = "file_kind" + i;
            String file_kind2 = request.getParameter(tem_file_kind);
            if (file_kinda.indexOf(file_kind2) != -1) n++;
          }
          if (n == 0) {
            if (p == 0) {
              if (vt.validata(
                          (String) dbSession.getAttribute("unit_db_name"),
                          "fund_apply_pay",
                          "apply_pay_ID",
                          apply_pay_ID,
                          "check_tag")
                      .equals("5")
                  || vt.validata(
                          (String) dbSession.getAttribute("unit_db_name"),
                          "fund_apply_pay",
                          "apply_pay_ID",
                          apply_pay_ID,
                          "check_tag")
                      .equals("9")) {
                String currency_name = "";
                String personal_unit = "";
                String chain_ID = "";
                String chain_name = "";
                String funder = "";
                String funder_ID = "";
                String sql11 =
                    "select * from fund_apply_pay where apply_pay_ID='" + apply_pay_ID + "'";
                ResultSet rs11 = fund_db.executeQuery(sql11);
                while (rs11.next()) {
                  chain_ID = rs11.getString("chain_ID");
                  chain_name = rs11.getString("chain_name");
                  funder = rs11.getString("human_name");
                  funder_ID = rs11.getString("human_ID");
                  currency_name = rs11.getString("currency_name");
                  personal_unit = rs11.getString("personal_unit");
                }
                int expenses_amount = 0;
                String sql6 =
                    "select count(*) from fund_apply_pay_details where apply_pay_ID='"
                        + apply_pay_ID
                        + "'";
                ResultSet rs6 = fund_db.executeQuery(sql6);
                if (rs6.next()) {
                  expenses_amount = rs6.getInt("count(*)");
                }
                double demand_cost_price_sum = 0.0d;
                for (int i = 1; i <= expenses_amount; i++) {
                  String tem_cost_price_subtotal = "cost_price_subtotal" + i;
                  String cost_price_subtotal2 = request.getParameter(tem_cost_price_subtotal);
                  demand_cost_price_sum += Double.parseDouble(cost_price_subtotal2);
                  sql6 =
                      "update fund_apply_pay_details set cost_price_subtotal='"
                          + cost_price_subtotal2
                          + "' where apply_pay_ID='"
                          + apply_pay_ID
                          + "' and details_number='"
                          + i
                          + "'";
                  fund_db.executeUpdate(sql6);
                }
                for (int i = 1; i < file_kind.length; i++) {
                  StringTokenizer tokenTO1 = new StringTokenizer(file_kind[i], "/");
                  String file_chain_ID = "";
                  String file_chain_name = "";
                  while (tokenTO1.hasMoreTokens()) {
                    file_chain_ID = tokenTO1.nextToken();
                    file_chain_name = tokenTO1.nextToken();
                  }
                  StringTokenizer tokenTO4 = new StringTokenizer(cost_price_subtotal[i], ",");
                  String cost_price_subtotal1 = "";
                  while (tokenTO4.hasMoreTokens()) {
                    cost_price_subtotal1 += tokenTO4.nextToken();
                  }
                  demand_cost_price_sum += Double.parseDouble(cost_price_subtotal1);
                  expenses_amount++;
                  String sql1 =
                      "insert into fund_apply_pay_details(apply_pay_ID,details_number,file_chain_ID,file_chain_name,cost_price_subtotal) values ('"
                          + apply_pay_ID
                          + "','"
                          + expenses_amount
                          + "','"
                          + file_chain_ID
                          + "','"
                          + file_chain_name
                          + "','"
                          + cost_price_subtotal1
                          + "')";
                  fund_db.executeUpdate(sql1);
                }

                String sql =
                    "update fund_apply_pay set demand_cost_price_sum='"
                        + demand_cost_price_sum
                        + "',check_tag='2',register_time='"
                        + register_time
                        + "',register='"
                        + register
                        + "',remark='"
                        + remark
                        + "' where apply_pay_ID='"
                        + apply_pay_ID
                        + "'";
                fund_db.executeUpdate(sql);

                response.sendRedirect("draft/fund/applyPayExpenses_ok.jsp?finished_tag=2");
              } else {
                response.sendRedirect("draft/fund/applyPayExpenses_ok.jsp?finished_tag=3");
              }
            } else {
              response.sendRedirect("draft/fund/applyPayExpenses_ok.jsp?finished_tag=6");
            }
          } else {
            response.sendRedirect("draft/fund/applyPayExpenses_ok.jsp?finished_tag=7");
          }
        } catch (Exception ex) {
          ex.printStackTrace();
        }
        fund_db.commit();
        fund_db1.commit();
        fund_db.close();
        fund_db1.close();
      } else {
        response.sendRedirect("error_conn.htm");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
コード例 #15
0
 public String[] getParameterValues(String name) {
   return request.getParameterValues(name);
 }
コード例 #16
0
ファイル: WebChartJSPTag.java プロジェクト: no2key/WebChart
  public void getEnv(VariableTable vt) {
    Enumeration e = null;
    HttpServletRequest request = (HttpServletRequest) (pageContext.getRequest());
    HttpSession session = request.getSession(false);

    String db_charset = "gb2312";
    String url_charset = null;

    vt.remove("SESSION.LOGINID");
    vt.remove("SESSION.LOGINNAME");
    vt.remove("SESSION.LOGINROLE");

    if (vt.exists("WEBCHART.DB_CHARSET")) {
      db_charset = vt.getString("WEBCHART.DB_CHARSET");
    }

    if (vt.exists("WEBCHART.URL_CHARSET")) {
      url_charset = vt.getString("WEBCHART.URL_CHARSET");
    }

    if (session != null) {
      e = session.getAttributeNames();
      while (e.hasMoreElements()) {
        String name = (String) e.nextElement();
        Object value = session.getAttribute(name);
        vt.add(name, java.sql.Types.VARCHAR);
        if (value != null) vt.setValue(name, value.toString());
      }
      vt.add("SESSION.ID", java.sql.Types.VARCHAR);
      vt.setValue("SESSION.ID", session.getId());
      vt.add("SESSION.CREATE", java.sql.Types.VARCHAR);
      vt.setValue(
          "SESSION.CREATE",
          DBOperation.toString(
              new java.util.Date(session.getCreationTime()), "yyyy-MM-dd HH:mm:ss"));
      vt.add("SESSION.ACCESS", java.sql.Types.VARCHAR);
      vt.setValue(
          "SESSION.ACCESS",
          DBOperation.toString(
              new java.util.Date(session.getLastAccessedTime()), "yyyy-MM-dd HH:mm:ss"));
    }
    e = request.getParameterNames();
    while (e.hasMoreElements()) {
      String name = (String) e.nextElement();
      String value = request.getParameter(name);
      ;
      String par_values[] = request.getParameterValues(name);
      name = name.toUpperCase();
      if (name.equalsIgnoreCase("WEBCHART.SECURITY")
          || name.equalsIgnoreCase("WEBCHART.DEFAULTACCESS")
          || name.equalsIgnoreCase("WEBCHART.ALLOW")
          || name.equalsIgnoreCase("WEBCHART.DENY")
          || name.equalsIgnoreCase("WEBCHART.IPSECURITY")
          || name.equalsIgnoreCase("WEBCHART.IPACCESS")
          || name.equalsIgnoreCase("WEBCHART.IPALLOW")
          || name.equalsIgnoreCase("WEBCHART.IPDENY")
          || name.equalsIgnoreCase("WEBCHART.XSLDOC")
          || name.equalsIgnoreCase("WEBCHART.IMAGEONLY")
          || name.equalsIgnoreCase("WEBCHART.XMLDATA")
          || name.equalsIgnoreCase("WEBCHART.LOGSQL")
          || name.equalsIgnoreCase("WEBCHART.DATATYPE")
          || name.equalsIgnoreCase("WEBCHART.URLS")
          || name.equalsIgnoreCase("WEBCHART.TOPURLS")
          || name.equalsIgnoreCase("WEBCHART.TOPCURR")
          || name.equalsIgnoreCase("WEBCHART.LEFTURLS")
          || name.equalsIgnoreCase("WEBCHART.LEFTCURR")
          || name.equalsIgnoreCase("WEBCHART.INPUTS")
          || name.equalsIgnoreCase("WEBCHART.CACHE")
          || name.equalsIgnoreCase("WEBCHART.DATA")
          || name.equalsIgnoreCase("WEBCHART.CSS")
          || name.equalsIgnoreCase("WEBCHART.RELOAD")
          || name.equalsIgnoreCase("WEBCHART.EXPIRE")
          || name.equalsIgnoreCase("WEBCHART.DMLKEY")
          || name.equalsIgnoreCase("WEBCHART.ENGINE")
          || name.equalsIgnoreCase("WEBCHART.EXCELURL")
          || name.equalsIgnoreCase("WEBCHART.DBID")
          || name.equalsIgnoreCase("WEBCHART.DBIDSEED")
          || name.equalsIgnoreCase("WEBCHART.SECUREFIELDS")
          || name.equalsIgnoreCase("WEBCHART.KEEP_CACHE_IMAGE")
          || name.equalsIgnoreCase("WEBCHART.KEEP_CACHE_TIME")
          || name.startsWith("WEBCHART.SECUREMEMO")
          || name.startsWith("WEBCHART.QUERY_")
          || name.startsWith("WEBCHART.HEADHTML_")
          || name.startsWith("WEBCHART.DATAHTML_")
          || name.startsWith("WEBCHART.VARLIST_")
          || name.startsWith("WEBCHART.FORALL_")
          || name.startsWith("WEBCHART.XMLDATA_")
          || name.startsWith("WEBCHART.TABLE_")
          || name.startsWith("WEBCHART.COLUMN_")
          || name.startsWith("SESSION.")) continue;
      if (name.startsWith("WEBCHART.") && !name.equals("WEBCHART.DOCTYPE")) continue;
      vt.add(name, java.sql.Types.VARCHAR);

      if (par_values != null && par_values.length > 1) {
        StringBuffer temp = new StringBuffer();
        for (int i = 0; i < par_values.length; i++) {
          if (par_values[i] != null && par_values[i].trim().length() > 0) {
            if (temp.length() > 0) {
              temp.append(",");
            }
            temp.append(par_values[i]);
          }
        }
        value = temp.toString();
      }
      if (url_charset != null) {
        try {
          value = new String(value.getBytes(url_charset), db_charset);
        } catch (java.io.UnsupportedEncodingException uee) {
        }
        ;
      }
      vt.setValue(name, value);
    }
    vt.add("REQUEST.REMOTEADDR", java.sql.Types.VARCHAR);
    vt.setValue("REQUEST.REMOTEADDR", getClientIPAddr());
    vt.add("REQUEST.REMOTEHOST", java.sql.Types.VARCHAR);
    vt.setValue("REQUEST.REMOTEHOST", request.getRemoteAddr());
    vt.add("REQUEST.REFERER", java.sql.Types.VARCHAR);
    vt.setValue("REQUEST.REFERER", request.getHeader("Referer"));
    vt.add("REQUEST.QUERYSTRING", java.sql.Types.VARCHAR);
    vt.setValue("REQUEST.QUERYSTRING", request.getQueryString());
  }
コード例 #17
0
ファイル: Fines_jsp.java プロジェクト: malus91/LMS
  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.glassfish.jsp.api.ResourceInjector)
              application.getAttribute("com.sun.appserv.jsp.resource.injector");

      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("<!DOCTYPE html>\n");
      out.write("<html>\n");
      out.write("    <head>\n");
      out.write(
          "        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n");
      out.write("        <title>Fine</title>\n");
      out.write("        <link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">    \n");
      out.write("\n");
      out.write("    </head>\n");
      out.write("    <body style = \"background-image: url(lib2.jpg)\">         \n");
      out.write("    <center>\n");
      out.write("        <h1>Update Fines information</h1>\n");
      out.write("        <form name=\"Update\" action=\"Fines_upd.jsp\">\n");
      out.write("            <table border=\"0\" width=\"3\" cellspacing=\"2\">\n");
      out.write("                <thead>\n");
      out.write("                    <tr>\n");
      out.write("                        <th>Update Fines</th>\n");
      out.write("                        <th></th>\n");
      out.write("                    </tr>\n");
      out.write("                </thead>\n");
      out.write("                <tbody>\n");
      out.write("                    <tr>\n");
      out.write("                        <td>Update Fine table with todays Data</td>\n");
      out.write(
          "                        <td><input type=\"submit\" value=\"Update / View Fines\" name=\"SUBMIT\"/></td>\n");
      out.write("                    </tr>\n");
      out.write("                </tbody>\n");
      out.write("            </table>           \n");
      out.write("        </form>\n");
      out.write("        <h1>Check your Fines Here</h1>\n");
      out.write("        <form name=\"Fines\" action=\"Fines.jsp\">\n");
      out.write("            <table border=\"0\" width=\"3\" cellspacing=\"2\">\n");
      out.write("                <thead>\n");
      out.write("                    <tr>\n");
      out.write("                        <th>Get Fine Details</th>\n");
      out.write("                        <th></th>\n");
      out.write("                    </tr>\n");
      out.write("                </thead>\n");
      out.write("                <tbody>\n");
      out.write("                    <tr>\n");
      out.write("                        <td>Card No</td>\n");
      out.write(
          "                        <td><input type=\"text\" name=\"Card_no\" value=\"\"/></td>\n");
      out.write("                    </tr>\n");
      out.write("                    <tr>\n");
      out.write("                        <td></td>\n");
      out.write(
          "                        <td><input type=\"submit\" value=\"Get Fines\" name=\"SUBMIT\" /></td>\n");
      out.write("                    </tr>\n");
      out.write("                </tbody>\n");
      out.write("            </table>        \n");
      out.write("            ");

      Connection con = null;
      String[] selected_Checkboxes = request.getParameterValues("chk");
      PreparedStatement pst = null;
      ResultSet result = null;
      ResultSet resUpd = null;
      con =
          DriverManager.getConnection(
              "jdbc:mysql://localhost:3306/lbms_db?zeroDateTimeBehavior=convertToNull",
              "root",
              "admin12");
      String Card_no = request.getParameter("Card_no");
      String button = null;
      Date dt = new Date();
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
      String current_date = sdf.format(dt);
      if (Card_no != null && selected_Checkboxes == null) {
        String selSql =
            "SELECT  l.card_no, SUM(f.fine_amt) AS total_fine, f.paid  "
                + "FROM book_loans l, fines f  "
                + "WHERE l.loan_id = f.loan_id AND "
                + "l.card_no = "
                + Card_no
                + " "
                + "GROUP BY l.card_no";
        pst = con.prepareStatement(selSql);
        result = pst.executeQuery();
        String box = null;
        String paid;
        String pay;
        Boolean chk = false;
        out.println("<table>");
        pay = "<form action='Fines.jsp'>";
        out.println(pay);
        out.println("<tr>");
        out.println("<th>Card No</th>");
        out.println("<th>Fine_Amt</th>");
        out.println("<th>Paid OR Not</th>");
        out.println("</tr>");
        while (result.next()) {
          chk = true;
          paid = "No";
          if (result.getBoolean("f.paid")) {
            paid = "Yes";
          }

          out.println("<tr>");
          out.println(
              "<td>"
                  + result.getInt("l.card_no")
                  + "</td><td>"
                  + result.getString("total_fine")
                  + "</td><td>"
                  + paid
                  + "</td>");
          out.print("<td>");
          box = "<input name='chk' value=" + result.getInt("l.card_no") + " type='checkbox'>";
          out.print(box);
          out.print("</td>");
          out.print("</tr>");
        }

        if (chk == true) {
          out.println("<tr>");
          out.print("<td>");
          button = "<input type='submit' value='Pay Fine' name='Pay'>";
          out.print(button);
          out.print("</td>");
          out.println("</tr>");
        } else {

          out.write(
              "<dialog open> <font color = 'green'>No Fine information. You owe nothing! Thank You</font> </dialog>");
        }
        out.println("</form>");
        out.println("</table>");
      } else if (selected_Checkboxes != null) {
        String sqlLoan = null;
        ResultSet resultLoan = null;
        String sqlUpdFine = null;
        PreparedStatement pstUpd = null;
        String sqlBook = null;
        ResultSet rsltBook = null;
        char chkouts = 'N';

        int length_chk = selected_Checkboxes.length;
        for (int i = 0; i < length_chk; i++) {
          // Check whether the Book is returned before paying the fine.
          sqlBook =
              "SELECT COUNT(loan_id) AS no_chkouts FROM book_loans WHERE card_no = "
                  + selected_Checkboxes[i]
                  + " AND date_in = '0000-00-00' AND due_date < "
                  + current_date
                  + "";
          pst = con.prepareStatement(sqlBook);
          rsltBook = pst.executeQuery();
          while (rsltBook.next()) {
            if (rsltBook.getInt("no_chkouts") > 0) {
              chkouts = 'Y';
            }
          }
          if (chkouts == 'Y') {

            out.write(
                "<dialog open> <font color = 'red'>You have outstanding due checkouts!. Please return the books and then Pay the fine</font> </dialog>");
          }
          // Get the corresponding loan_Ids for each customer from Fines table

          sqlLoan =
              "SELECT loan_id FROM book_loans WHERE card_no = "
                  + selected_Checkboxes[i]
                  + " AND date_in IS NOT NULL AND due_date < date_in";
          pst = con.prepareStatement(sqlLoan);
          resultLoan = pst.executeQuery();
          while (resultLoan.next()) {
            sqlUpdFine =
                "UPDATE fines SET paid = true WHERE loan_id = " + resultLoan.getInt("loan_id") + "";
            pstUpd = con.prepareStatement(sqlUpdFine);
            pstUpd.executeUpdate();
            out.println("Payment Updated Successfully");
          }
        }
      }

      out.write("\n");
      out.write("        </form>        \n");
      out.write("    </center>\n");
      out.write("</body>\n");
      out.write("</html>\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);
        else throw new ServletException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
コード例 #18
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    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 {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html;charset=gb2312");
      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;

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

      String path = request.getContextPath();
      String basePath =
          request.getScheme()
              + "://"
              + request.getServerName()
              + ":"
              + request.getServerPort()
              + path
              + "/";

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

      response.reset();
      response.setContentType("application/msexcel");
      response.setHeader("Content-disposition", "inline;filename=tqgbstudent.xls"); // 定义文件名
      DecimalFormat f = new DecimalFormat("#,##0.00");
      HSSFWorkbook wb = new HSSFWorkbook();
      HSSFSheet sheet = wb.createSheet("sheet1");
      String[] id = request.getParameterValues("id");
      String[] name = request.getParameterValues("name");
      String[] xuehao = request.getParameterValues("xuehao");
      String[] sex = request.getParameterValues("sex");
      String[] sszy = request.getParameterValues("sszy");
      String[] nbzy = request.getParameterValues("nbzy");
      String[] sd = request.getParameterValues("sd");
      String[] nbbd = request.getParameterValues("nbbd");
      String[] cjpm = request.getParameterValues("cjpm");
      String[] beizhu = request.getParameterValues("beizhu");
      String[] tel = request.getParameterValues("tel");

      // 以下以写表头
      // 表头为第一行
      HSSFRow row = sheet.createRow((short) 0);
      // 定义10列
      HSSFCell cell1 = row.createCell((short) 0);
      HSSFCell cell2 = row.createCell((short) 1);
      HSSFCell cell3 = row.createCell((short) 2);
      HSSFCell cell4 = row.createCell((short) 3);
      HSSFCell cell5 = row.createCell((short) 4);
      HSSFCell cell6 = row.createCell((short) 5);
      HSSFCell cell7 = row.createCell((short) 6);
      HSSFCell cell8 = row.createCell((short) 7);
      HSSFCell cell9 = row.createCell((short) 8);
      HSSFCell cell10 = row.createCell((short) 9);
      HSSFCell cell11 = row.createCell((short) 10);

      cell1.setEncoding((short) 1);
      cell1.setCellType(1);
      cell2.setEncoding((short) 1);
      cell2.setCellType(1);
      cell3.setEncoding((short) 1);
      cell3.setCellType(1);
      cell4.setEncoding((short) 1);
      cell4.setCellType(1);
      cell5.setEncoding((short) 1);
      cell5.setCellType(0);
      cell6.setEncoding((short) 1);
      cell6.setCellType(1);
      cell7.setEncoding((short) 1);
      cell7.setCellType(1);
      cell8.setEncoding((short) 1);
      cell8.setCellType(1);
      cell9.setEncoding((short) 1);
      cell9.setCellType(1);
      cell10.setEncoding((short) 1);
      cell10.setCellType(1);
      cell11.setEncoding((short) 1);
      cell11.setCellType(1);
      // 定义表头的内容
      cell1.setCellValue("序号");
      cell2.setCellValue("姓名");
      cell3.setCellValue("学号");
      cell4.setCellValue("性别");
      cell5.setCellValue("硕士专业");
      cell6.setCellValue("拟报博士专业");
      cell7.setCellValue("原硕导");
      cell8.setCellValue("拟报博导");
      cell9.setCellValue("学位课加权成绩排名");
      cell10.setCellValue("备注");
      cell11.setCellValue("联系方式");

      for (int i = 0; i < name.length; i++) {
        // 定义数据从第二行开始
        row = sheet.createRow((short) i + 1);
        cell1 = row.createCell((short) 0);
        cell2 = row.createCell((short) 1);
        cell3 = row.createCell((short) 2);
        cell4 = row.createCell((short) 3);
        cell5 = row.createCell((short) 4);
        cell6 = row.createCell((short) 5);
        cell7 = row.createCell((short) 6);
        cell8 = row.createCell((short) 7);
        cell9 = row.createCell((short) 8);
        cell10 = row.createCell((short) 9);
        cell11 = row.createCell((short) 10);

        cell1.setEncoding((short) 1);
        cell1.setCellType(1);
        cell2.setEncoding((short) 1);
        cell2.setCellType(1);
        cell3.setEncoding((short) 1);
        cell3.setCellType(1);
        cell4.setEncoding((short) 1);
        cell4.setCellType(1);
        cell5.setEncoding((short) 1);
        cell5.setCellType(0);
        cell6.setEncoding((short) 1);
        cell6.setCellType(1);
        cell7.setEncoding((short) 1);
        cell7.setCellType(1);
        cell8.setEncoding((short) 1);
        cell8.setCellType(1);
        cell9.setEncoding((short) 1);
        cell9.setCellType(1);
        cell10.setEncoding((short) 1);
        cell10.setCellType(1);
        cell11.setEncoding((short) 1);
        cell11.setCellType(1);

        // 填充内容
        cell1.setCellValue(id[i]);
        cell2.setCellValue(name[i]);
        cell3.setCellValue(xuehao[i]);
        cell4.setCellValue(sex[i]);
        cell5.setCellValue(sszy[i]);
        cell6.setCellValue(nbzy[i]);
        cell7.setCellValue(sd[i]);
        cell8.setCellValue(nbbd[i]);
        cell9.setCellValue(cjpm[i]);
        cell10.setCellValue(beizhu[i]);
        cell11.setCellValue(tel[i]);
      }
      wb.write(response.getOutputStream());
      response.getOutputStream().flush();
      response.getOutputStream().close();

    } 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 {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
コード例 #19
0
  public void service(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    Connection con = null;

    String bnm[] = req.getParameterValues("Comics");

    String qty[] = new String[bnm.length];
    ArrayList al1 = new ArrayList();
    ArrayList al2 = new ArrayList();
    for (int i = 0; i < bnm.length; i++) {
      qty[i] = req.getParameter(bnm[i]);
      al1.add(bnm[i]);
      al2.add(qty[i]);
    }

    HttpSession HSession = req.getSession(true);

    ArrayList alo1 = (ArrayList) HSession.getValue("bNames");
    ArrayList alo2 = (ArrayList) HSession.getValue("bQty");

    al1.addAll(alo1);
    al2.addAll(alo2);

    HSession.putValue("bNames", al1);
    HSession.putValue("bQty", al2);

    out.println("<html>");
    out.println("<title>Categories..</title>");
    out.println("<body bgcolor=gold >");

    out.println("<b><font face=\"Papyrus\" size=36 color= #806F7E><center>");
    out.println("<big>Category</big></center>");

    out.println("<ul type=disc>");
    out.println("<font face=\"Maiandra GD\" color=black size=4>");
    out.println("<li type=square>Choose your category..");
    out.println("</li></font><br>");

    out.println(
        "<A href=\"FictionClick\"><font face=\"Mistral\" size=8 color=#208234><b>Fiction</b></A><br>");

    out.println(
        "<A href=\"NonFictionClick\"><font face=\"Mistral\" size=8 color=#208234><b>Non-Fiction</b></A><br>");

    out.println(
        "<A href=\"AutobiographyClick\"><font face=\"Mistral\" size=8 color=#208234><b>Autobiography</b></A><br>");

    out.println(
        "<A href=\"HistoryClick\"><font face=\"Mistral\" size=8 color=#208234><b>History</b></A><br>");

    out.println(
        "<A href=\"ComicsClick\"><font face=\"Mistral\" size=8 color=#208234><b>Comics</b></A></font><br><br>");

    out.println("<center><form action=\"http://localhost:8080/servlet/FinalList\">");
    out.println("<input type=submit value=\" Finalize List >>\"></form>");

    out.println("<font face=\"Maiandra GD\" color=black size=4>");
    out.println("Moves to final List..</center>");

    out.println("</font></body>");
    out.println("</html>");
  } // service
コード例 #20
0
ファイル: StartStress.java プロジェクト: kgnt/JavaLearn
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    if (!runFlag) {
      refreshCount++;
      System.out.println("Refresh " + refreshCount + " times......");

      // redirect to index.jsp
      request.getRequestDispatcher("/index.jsp").forward(request, response);

      return;
    }

    // response.setContentType("text/html;charset=GBK");
    request.setCharacterEncoding("GBK");
    // PrintWriter out = response.getWriter();

    // get global parameters from web
    projectName = request.getParameter("projectName");
    serverIp = request.getParameter("serverIp");
    startServerCmd = request.getParameter("startServerCmd");
    System.out.println("get projectName from web: " + projectName);
    System.out.println("get serverIp from web: " + serverIp);
    System.out.println("get startServerCmd from web: " + startServerCmd);

    // get stress parameters from web
    startStressCmd = request.getParameter("startStressCmd");
    stressLog = request.getParameter("stressLog");
    stressName = request.getParameter("stressName");
    System.out.println("get startStressCmd from web: " + startStressCmd);
    System.out.println("get stressName from web: " + stressName);

    // get stress IP from web
    String[] clients = request.getParameterValues("client");
    int clientsLen = clients.length;
    System.out.println("get clients count from web: " + clientsLen);
    if (clientsLen != 0) {
      for (String client : clients) {
        System.out.println("get client from web: " + client);

        // change projectName in client.config
        sc.modifyConfigFile(client, clientConfig, PROJECT_NAME, projectName);
        sc.modifyConfigFile(client, clientConfig, MONITOR_PROCESS, stressName);
        sc.modifyConfigFile(client, clientConfig, MONITOR_LOG, stressLog);
      }
    } else {
      System.err.println("get no client!!!");
      return;
    }

    // start servers
    System.out.println("start servers......");
    String startServerRet = (String) (sc.executeCmd(serverIp, startServerCmd, String.class));
    System.out.println(startServerRet);

    sc.waitto(15);

    // start stress
    System.out.println("start stress......");
    for (String client : clients) {
      System.out.println("start stress on " + client + "......");
      String startStressRet = (String) (sc.executeCmd(client, startStressCmd, String.class));
      System.out.println("result: " + startStressRet);
    }
    sc.waitto(15);

    // start clients
    for (String client : clients) {
      System.out.println("start client on " + client + "......");
      sc.executeCmd(client, startClientCmd);
    }

    // redirect to index.jsp
    request.getRequestDispatcher("/index.jsp").forward(request, response);

    runFlag = false;

    // String cmd = "cd /home/admin/ashu/ycsb && ./run.sh workload put @";\

    // if (ret1 != null && ret2 != null && ret3 != null) {
    // out.println("get host by staf: " + ret1);
    // out.println("<br>");
    // out.println("get host by staf: " + ret2);
    // out.println("<br>");
    // out.println("get host by staf: " + ret3);
    // out.println("<br>");
    // }

    // out.close();

    // Enumeration paramNames = request.getParameterNames();
    // while (paramNames.hasMoreElements()) {
    // String paramName = (String) paramNames.nextElement();
    // out.print("<TR><TD>" + paramName + "<TD>");
    // out.println("<BR>");//print new line
    // String[] paramValues = request.getParameterValues(paramName);
    // if (paramValues.length == 1) {
    // String paramValue = paramValues[0];
    // if (paramValue.length() == 0)
    // out.println("<I>No Value</I>");
    // else
    // out.println(paramValue);
    // } else {
    // out.println("<UL>");
    // for (int i = 0; i < paramValues.length; i++) {
    // out.println("<LI>" + paramValues[i]);
    // }
    // out.println("</UL>");
    // }
    // }
  }
コード例 #21
0
ファイル: AddProjectServlet.java プロジェクト: ideaesb/paws
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    System.out.println("AddProjectServlet.doPost Entered...");

    init(response);
    PrintWriter out = response.getWriter();
    dataSource = (DataSource) request.getSession().getServletContext().getAttribute("DBCPool");
    baseurl = config.getServletContext().getInitParameter("baseurl"); // filesystem web-root
    parameterDAO.setDataSource(dataSource);
    pb.setParameterDAO(parameterDAO);
    filter.setParameterDAO(parameterDAO);

    System.out.println("AddProjectServlet.doPost done inits pb.set, filter.set...");

    if (ParameterDAO.parse(request.getParameter("clearmsgs"))) {
      msg = new StringBuffer();
    }

    String[] deleted = request.getParameterValues("delete");
    String addnew = request.getParameter("addnew");
    String updated = request.getParameter("updated");
    String undelete = request.getParameter("undelete");
    String searchbyx = request.getParameter("searchbyx");

    filter.setSearchString(StringUtils.trimToEmpty(request.getParameter("search")));
    String sortby = StringUtils.trimToEmpty(request.getParameter("sortby"));

    String order = "DESC";
    if (!ParameterDAO.parse(request.getParameter("order"))) order = "ASC";

    // if coming from addContacts, success or failure...
    if (ParameterDAO.parse(request.getAttribute("addcontacts"))
        || ParameterDAO.parse(request.getAttribute("addagencies"))
        || ParameterDAO.parse(request.getAttribute("uploadedfile"))) {
      msg.append(StringUtils.trimToEmpty((String) request.getAttribute("msg")));
    } else if (StringUtils.isNotBlank(filter.getSearchString())) {
      // triggers the simple search exclusive of any other action (safe from delete, by preceding in
      // if-then )
      // do absolutely nothing the search field will be populated just fine as expected.  Later, may
      // be add X number of projects
    } else if (deleted == null) {
      // System.out.println("AddProjectServlet.doPost Entered else if deleted == null");

      // coming from index.jsp
      if (ParameterDAO.parse(updated)) {
        addProject(request, response, true);
      } else if (ParameterDAO.parse(undelete)) {
        parameterDAO.unDeleteAllProjects();
      } else if (ParameterDAO.parse(addnew)) {
        addProject(request, response, false);
      } else if (ParameterDAO.parse(searchbyx)) {
        // we are just setting filter
        setProjectBean(request);
        filter = pb;
        System.out.println("Filter STARTS LIFE as = " + filter.toFilterString());
        // System.out.println("Filter Training INIT parsed as = " +
        // ParameterDAO.parse(filter.getTraining()));
        // System.out.println("Filter Capability Area(s) INIT as = " + filter.getCapabilityAreas());

        msg.append("Advanced Search Parameters = ");
        msg.append(
            "<div style=\"font-family: 'trebuchet ms', sans-serif;  font-size: 9px; font-style: italic; text-transform: lowercase; display: inline; \">");
        msg.append(filter.toFilterString());
        msg.append("</div><br />");
      }
    } else if (deleted.length == 0) {
      // came from projects list but nothing to do...later when table cells are editable, we may @TO
      // DO capture all edits/updates here
    } else {
      parameterDAO.deleteProject(deleted);
      int count = 0;
      for (int i = 0; i < deleted.length; i++) {
        count++;

        if (count == 1) {
          msg.append("Project(s) <strong><span style=\"background-color: #FFFF00\">");
        } else {
          msg.append(",&nbsp;<strong><span style=\"background-color: #FFFF00\">");
        }
        msg.append(
            StringEscapeUtils.escapeHtml(
                parameterDAO.getJustOneProject(deleted[i]).getProjectname()));
        msg.append("</span></strong>");
      }
      if (count > 0) msg.append(" D E L E T E D<BR />");
    }

    /////////////////////////////////////////////
    //  Draw the projects list table
    //
    out.println(getHeader());
    out.println(getMessageTable(msg));
    // System.out.println("AddProjectServlet.doPost drawing projects table " + filter.toString());

    if (StringUtils.isBlank(sortby)) {
      out.println(getProjectsListHTML());
    } else if (StringUtils.equalsIgnoreCase(sortby, "code")) {
      out.println(getProjectsListHTML("code", order));
    } else if (StringUtils.equalsIgnoreCase(sortby, "name")) {
      out.println(getProjectsListHTML("nametitle", order));
    } else if (StringUtils.equalsIgnoreCase(sortby, "description")) {
      out.println(getProjectsListHTML("description", order));
    } else if (StringUtils.equalsIgnoreCase(sortby, "status")) {
      out.println(getProjectsListHTML("status", order));
    } else {
      out.println(getProjectsListHTML());
    }

    out.println(getFooter());
    filter = new ProjectBean();
    // System.out.println("AddProjectServlet.doPost DONE");

  }
コード例 #22
0
ファイル: key_register_ok.java プロジェクト: RainerJava/erp-6
  public synchronized void service(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    HttpSession dbSession = request.getSession();
    JspFactory _jspxFactory = JspFactory.getDefaultFactory();
    PageContext pageContext =
        _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
    ServletContext dbApplication = dbSession.getServletContext();

    try {

      HttpSession session = request.getSession();
      PrintWriter out = response.getWriter();

      nseer_db_backup1 security_db = new nseer_db_backup1(dbApplication);
      if (security_db.conn((String) dbSession.getAttribute("unit_db_name"))) {
        getRecordCount query = new getRecordCount();

        String tablename = request.getParameter("tablename");
        String[] cols = request.getParameterValues("col");

        if (cols == null) {

          response.sendRedirect("hr/config/key/key_register_ok_a.jsp");

        } else {
          String column_group = "";
          for (int i = 0; i < cols.length; i++) {
            column_group += cols[i] + ",";
          }
          column_group = column_group.substring(0, column_group.length() - 1);
          String sql1 =
              "select * from security_publicconfig_key where tablename='" + tablename + "'";
          ResultSet rs = security_db.executeQuery(sql1);
          if (rs.next()) {
            String sql =
                "update security_publicconfig_key set column_group='"
                    + column_group
                    + "' where tablename='"
                    + tablename
                    + "'";
            security_db.executeUpdate(sql);
          } else {
            String sql =
                "insert into security_publicconfig_key(tablename,column_group) values('"
                    + tablename
                    + "','"
                    + column_group
                    + "')";
            security_db.executeUpdate(sql);
          }

          response.sendRedirect("hr/config/key/key_register_ok_b.jsp");
        }
        security_db.commit();
        security_db.close();

      } else {
        response.sendRedirect("error_conn.htm");
      }
    } catch (Exception ex) {
    }
  }
コード例 #23
0
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String actionName = "";
    String pathInfo = request.getPathInfo();
    String destinationPage = ERROR_PAGE;

    if (inventory == null) {
      String errorMessage = "Inventory EJB reference is null.";
      request.setAttribute(ERROR_KEY, errorMessage);
    } else {

      if (pathInfo != null) {
        actionName = pathInfo.substring(1); // Get the action name from the HTTP Request.
      }

      // perform action
      if (VIEW_CAR_LIST_ACTION.equals(actionName)) {
        request.setAttribute("carList", inventory.listAvailableCars());
        destinationPage = "/carList.jsp";
      } else if (ADD_CAR_ACTION.equals(actionName)) {
        request.setAttribute("car", new CarDTO());
        destinationPage = "/carForm.jsp";
      } else if (EDIT_CAR_ACTION.equals(actionName)) {
        int id = Integer.parseInt(request.getParameter("id"));
        request.setAttribute("car", inventory.findCar(id));
        destinationPage = "/carForm.jsp";
      } else if (SAVE_CAR_ACTION.equals(actionName)) {
        // build the car from the request parameters
        CarDTO car = new CarDTO();
        car.setId(Integer.parseInt(request.getParameter("id")));
        car.setMake(request.getParameter("make"));
        car.setModel(request.getParameter("model"));
        car.setModelYear(request.getParameter("modelYear"));

        // save the car
        inventory.saveCar(car);

        // prepare the list
        request.setAttribute("carList", inventory.listAvailableCars());
        destinationPage = "/carList.jsp";
      } else if (DELETE_CAR_ACTION.equals(actionName)) {
        // get list of ids to delete
        String[] ids = request.getParameterValues("id");

        // delete the list of ids

        inventory.deleteCars(ids);

        // prepare the list
        request.setAttribute("carList", inventory.listAvailableCars());
        destinationPage = "/carList.jsp";
      } else if (VIEW_BUY_CAR_FORM_ACTION.equals(actionName)) {
        int id = Integer.parseInt(request.getParameter("id"));
        request.setAttribute("car", inventory.findCar(id));
        destinationPage = "/buyCarForm.jsp";
      } else if (BUY_CAR_ACTION.equals(actionName)) {
        int carId = Integer.parseInt(request.getParameter("id"));
        double price;

        // Use $5000.00 as the default price if the user enters bad data.
        try {
          price = Double.parseDouble(request.getParameter("price"));
        } catch (NumberFormatException nfe) {
          price = 5000.00;
        }

        System.out.println("carId = [" + carId + "], price = [" + price + "]");

        // mark the car as sold
        inventory.buyCar(carId, price);

        // prepare the list
        request.setAttribute("carList", inventory.listAvailableCars());
        destinationPage = "/carList.jsp";
      } else {
        String errorMessage = "[" + actionName + "] is not a valid action.";
        request.setAttribute(ERROR_KEY, errorMessage);
      }
    }

    // Redirect to destination page.
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(destinationPage);

    dispatcher.forward(request, response);
  }
コード例 #24
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    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 {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html");
      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;

      out.write("\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n");
      org.jivesoftware.util.WebManager webManager = null;
      synchronized (_jspx_page_context) {
        webManager =
            (org.jivesoftware.util.WebManager)
                _jspx_page_context.getAttribute("webManager", PageContext.PAGE_SCOPE);
        if (webManager == null) {
          webManager = new org.jivesoftware.util.WebManager();
          _jspx_page_context.setAttribute("webManager", webManager, PageContext.PAGE_SCOPE);
        }
      }
      out.write('\r');
      out.write('\n');

      webManager.init(request, response, session, application, out);
      boolean save = request.getParameter("save") != null;
      boolean success = request.getParameter("success") != null;
      String persistentRosterParam = request.getParameter("persistentEnabled");
      boolean persistentRoster =
          persistentRosterParam == null ? false : persistentRosterParam.equals("true");

      String ignoreSubdomainsParam = request.getParameter("ignoreSubdomains");
      boolean ignnoreSubdomains =
          ignoreSubdomainsParam == null ? false : ignoreSubdomainsParam.equals("true");
      String blockPresencesParam = request.getParameter("blockPresences");
      boolean blockPresences =
          blockPresencesParam == null ? false : blockPresencesParam.equals("true");

      String sparkdiscoParam = request.getParameter("sparkDiscoInfo");
      boolean sparkDiscoInfo = sparkdiscoParam == null ? false : sparkdiscoParam.equals("true");

      String iqLastFilterPram = request.getParameter("iqLastFilter");
      boolean iqLastFilter = iqLastFilterPram == null ? false : iqLastFilterPram.equals("true");

      String mucFilterParam = request.getParameter("mucFilter");
      boolean mucFilter = mucFilterParam == null ? false : mucFilterParam.equals("true");

      String gajimBroadcastParam = request.getParameter("gajimBroadcast");
      boolean gajimBroadcast =
          gajimBroadcastParam == null ? false : gajimBroadcastParam.equals("true");

      String[] componentsEnabled = request.getParameterValues("enabledComponents[]");
      PermissionManager _pmanager = new PermissionManager();
      DatabaseManager _db;

      Map<String, String> errors = new HashMap<String, String>();
      if (save) {
        for (String property : JiveGlobals.getPropertyNames("plugin.remoteroster.jids")) {
          JiveGlobals.deleteProperty(property);
        }
        if (componentsEnabled != null) {
          for (int i = 0; i < componentsEnabled.length; i++) {
            JiveGlobals.setProperty("plugin.remoteroster.jids." + componentsEnabled[i], "true");
            String group = request.getParameter("input_group." + componentsEnabled[i]);
            if (group != null) {
              _pmanager.setGroupForGateway(componentsEnabled[i], group);
            }
          }
        }
        JiveGlobals.setProperty(
            "plugin.remoteroster.persistent", (persistentRoster ? "true" : "false"));
        JiveGlobals.setProperty(
            "plugin.remoteroster.blockPresences", (blockPresences ? "true" : "false"));
        JiveGlobals.setProperty(
            "plugin.remoteroster.sparkDiscoInfo", (sparkDiscoInfo ? "true" : "false"));
        JiveGlobals.setProperty(
            "plugin.remoteroster.iqLastFilter", (iqLastFilter ? "true" : "false"));
        JiveGlobals.setProperty("plugin.remoteroster.mucFilter", (mucFilter ? "true" : "false"));
        JiveGlobals.setProperty(
            "plugin.remoteroster.gajimBroadcast", (gajimBroadcast ? "true" : "false"));
        JiveGlobals.setProperty(
            "plugin.remoteroster.ignoreSubdomains", (ignnoreSubdomains ? "true" : "false"));
        response.sendRedirect("rr-main.jsp?success=true");
        return;
      }

      // Get the session manager
      SessionManager sessionManager = webManager.getSessionManager();

      Collection<ComponentSession> sessions = sessionManager.getComponentSessions();

      _db = DatabaseManager.getInstance();

      out.write(
          "\r\n\r\n<html>\r\n<head>\r\n<title>Gojara Settings</title>\r\n<link href=\"./css/rr.css\" rel=\"stylesheet\" type=\"text/css\">\r\n<script src=\"./js/http.js\" type=\"text/javascript\"></script>\r\n<script src=\"./js/jquery.js\" type=\"text/javascript\"></script>\r\n<script src=\"./js/rr.js\" type=\"text/javascript\"></script>\r\n<script src=\"./js/jquery.sparkline.js\" type=\"text/javascript\"></script>\r\n<script src=\"./js/jquery.horiz-bar-graph.js\" type=\"text/javascript\"></script>\r\n<!--[if lte IE 8]><script language=\"javascript\" type=\"text/javascript\" src=\"./js/excanvas.min.js\"></script><![endif]-->\r\n<script language=\"javascript\" type=\"text/javascript\" src=\"./js/jquery.flot.js\"></script>\r\n<script language=\"javascript\" type=\"text/javascript\" src=\"./js/jquery.flot.pie.js\"></script>\r\n\r\n<meta name=\"pageID\" content=\"remoteRoster\" />\r\n<meta name=\"helpPage\" content=\"\" />\r\n\r\n</head>\r\n<body>\r\n\r\n\t<p>Any components configured here will allow the external component associated with them full control over their\r\n\t\tdomain within any user's roster. Before enabling Remote Roster Management support for an external component, first\r\n");
      out.write(
          "\t\tconnect it like you would any external component. Once it has connected and registered with Openfire, it's JID should\r\n\t\tshow up below and you can enable Remote Roster support.</p>\r\n\r\n\t");

      if (success) {

        out.write(
            "\r\n\r\n\t<div class=\"jive-success\">\r\n\t\t<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\t\t\t<tbody>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td class=\"jive-icon\"><img src=\"images/success-16x16.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"\"></td>\r\n\t\t\t\t\t<td class=\"jive-icon-label\">Settings saved!</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</tbody>\r\n\t\t</table>\r\n\t</div>\r\n\t<br>\r\n\r\n\t");

      } else if (errors.size() > 0) {

        out.write(
            "\r\n\r\n\t<div class=\"jive-error\">\r\n\t\t<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\t\t\t<tbody>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td class=\"jive-icon\"><img src=\"images/error-16x16.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"\"></td>\r\n\t\t\t\t\t<td class=\"jive-icon-label\">Error saving settings!</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</tbody>\r\n\t\t</table>\r\n\t</div>\r\n\t<br>\r\n\r\n\t");
      }

      out.write(
          "\r\n\r\n\t<form action=\"rr-main.jsp?save\" method=\"post\">\r\n\r\n\t\t<div class=\"jive-contentBoxHeader\">Connected Gateway Components</div>\r\n\t\t<div class=\"jive-contentBox\">\r\n\r\n\t\t\t<p>Select which components you want to enable remote roster on:</p>\r\n\t\t\t");

      boolean gatewayFound = false;
      int i = 0;
      for (ComponentSession componentSession : sessions) {
        if (!componentSession.getExternalComponent().getCategory().equals("gateway")) {
          continue;
        }
        gatewayFound = true;

        long incoming = componentSession.getNumClientPackets();
        long outgoing = componentSession.getNumServerPackets();
        long both = incoming + outgoing;
        int incomingPercent = (int) (incoming * 100 / both);
        int outgoingPercent = (int) (outgoing * 100 / both);

        out.write(
            "\r\n\t\t\t<table class=\"gatewayHeader\">\r\n\t\t\t\t<tbody>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td class=\"gatewayCheckbox\"><input type=\"checkbox\" name=\"enabledComponents[]\"\r\n\t\t\t\t\t\t\tvalue=\"");
        out.print(componentSession.getExternalComponent().getInitialSubdomain());
        out.write("\"\r\n\t\t\t\t\t\t\t");
        out.print(
            JiveGlobals.getBooleanProperty(
                    "plugin.remoteroster.jids."
                        + componentSession.getExternalComponent().getInitialSubdomain(),
                    false)
                ? "checked=\"checked\""
                : "");
        out.write(" />\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t<td class=\"gatewayName\">");
        out.print(componentSession.getExternalComponent().getName());
        out.write(
            "</td>\r\n\t\t\t\t\t\t<td class=\"gatewayIcons\"><img src=\"images/log-16x16.png\" onclick=\"slideToggle('#logs");
        out.print(i);
        out.write(
            "')\"><img\r\n\t\t\t\t\t\t\tsrc=\"images/permissions-16x16.png\" id=\"showPermissions\" onclick=\"slideToggle('#permission");
        out.print(i);
        out.write(
            "')\"><img\r\n\t\t\t\t\t\t\tsrc=\"images/info-16x16.png\" id=\"showConfig\" onclick=\"slideToggle('#config");
        out.print(i);
        out.write(
            "')\"></td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</tbody>\r\n\t\t\t</table>\r\n\t\t\t<div id=\"config");
        out.print(i);
        out.write(
            "\" class=\"slider\">\r\n\t\t\t\t<div class=\"sildeHeader\">Information</div>\r\n\t\t\t\t<table class=\"configTable\">\r\n\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t<tr id=\"logodd\">\r\n\t\t\t\t\t\t\t<td width=\"200px\">Domain:</td>\r\n\t\t\t\t\t\t\t<td>");
        out.print(componentSession.getExternalComponent().getInitialSubdomain());
        out.write(
            "</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logeven\">\r\n\t\t\t\t\t\t\t<td>Status:</td>\r\n\t\t\t\t\t\t\t<td>Online</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logodd\">\r\n\t\t\t\t\t\t\t<td>Packages Send/Received:</td>\r\n\t\t\t\t\t\t\t<td><dl class=\"browser-data\" title=\"\">\r\n\t\t\t\t\t\t\t\t\t<dt>Incoming</dt>\r\n\t\t\t\t\t\t\t\t\t<dd>");
        out.print(incomingPercent);
        out.write("</dd>\r\n\t\t\t\t\t\t\t\t\t<dt>Outgoing</dt>\r\n\t\t\t\t\t\t\t\t\t<dd>");
        out.print(outgoingPercent);
        out.write(
            "</dd>\r\n\t\t\t\t\t\t\t\t</dl></td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</tbody>\r\n\t\t\t\t</table>\r\n\t\t\t</div>\r\n\t\t\t<div id=\"permission");
        out.print(i);
        out.write(
            "\" class=\"slider\">\r\n\t\t\t\t<div class=\"sildeHeader\">Access control</div>\r\n\t\t\t\t<table class=\"groupTable\">\r\n\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t<tr id=\"loghead\">\r\n\t\t\t\t\t\t\t<td colspan=\"3\">You can limit the access to the external component to an existing group</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td class=\"permissionTableColumn\">Groupname:</td>\r\n\t\t\t\t\t\t\t<td><input class=\"groupInput\" type=\"text\" id=\"groupSearch");
        out.print(i);
        out.write("\"\r\n\t\t\t\t\t\t\t\tname=\"input_group.");
        out.print(componentSession.getExternalComponent().getInitialSubdomain());
        out.write("\" alt=\"Find Groups\"\r\n\t\t\t\t\t\t\t\tonkeyup=\"searchSuggest('");
        out.print(i);
        out.write("');\" autocomplete=\"off\"\r\n\t\t\t\t\t\t\t\tvalue=\"");
        out.print(
            _pmanager.getGroupForGateway(
                componentSession.getExternalComponent().getInitialSubdomain()));
        out.write("\">\r\n\t\t\t\t\t\t\t\t<div id=\"search_suggest");
        out.print(i);
        out.write(
            "\"></div></td>\r\n\t\t\t\t\t\t\t<td style=\"vertical-align: top;\">\r\n\t\t\t\t\t\t\t\t<div class=\"ajaxloading\" id=\"ajaxloading");
        out.print(i);
        out.write(
            "\"></div>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</tbody>\r\n\t\t\t\t</table>\r\n\t\t\t</div>\r\n\t\t\t<div id=\"logs");
        out.print(i);
        out.write("\" class=\"slider\">\r\n\t\t\t\t");

        int iqs =
            _db.getPacketCount(
                componentSession.getExternalComponent().getInitialSubdomain(),
                Class.forName("org.xmpp.packet.IQ"));
        int msgs =
            _db.getPacketCount(
                componentSession.getExternalComponent().getInitialSubdomain(),
                Class.forName("org.xmpp.packet.Message"));
        int rosters =
            _db.getPacketCount(
                componentSession.getExternalComponent().getInitialSubdomain(),
                Class.forName("org.xmpp.packet.Roster"));
        int presences =
            _db.getPacketCount(
                componentSession.getExternalComponent().getInitialSubdomain(),
                Class.forName("org.xmpp.packet.Presence"));

        out.write(
            "\r\n\t\t\t\t<div class=\"sildeHeader\">Logs & Statistics</div>\r\n\r\n\t\t\t\t<table class=\"logtable\">\r\n\t\t\t\t\t<tfoot>\r\n\t\t\t\t\t\t<tr id=\"logfoot\">\r\n\t\t\t\t\t\t\t<td colspan=\"2\">Packages being logged for ");
        out.print(JiveGlobals.getIntProperty("plugin.remoteroster.log.cleaner.minutes", 60));
        out.write(
            "\r\n\t\t\t\t\t\t\t\tminutes\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t<td><a style=\"float: right;\"\r\n\t\t\t\t\t\t\t\tonClick=\"window.open('liveStats.jsp?component=");
        out.print(componentSession.getExternalComponent().getInitialSubdomain());
        out.write(
            "','mywindow','width=1200,height=700')\">Show\r\n\t\t\t\t\t\t\t\t\trealtime Log</a>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</tfoot>\r\n\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t<tr id=\"loghead\">\r\n\t\t\t\t\t\t\t<td width=\"200px\">Paket type</td>\r\n\t\t\t\t\t\t\t<td width=\"100px\">Number</td>\r\n\t\t\t\t\t\t\t<td></td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logodd\">\r\n\t\t\t\t\t\t\t<td>IQ</td>\r\n\t\t\t\t\t\t\t<td id=\"logiq");
        out.print(i);
        out.write('"');
        out.write('>');
        out.print(iqs);
        out.write("</td>\r\n\t\t\t\t\t\t\t<td rowspan=\"5\"><div id=\"pie");
        out.print(i);
        out.write(
            "\" class=\"graph\"></div></td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logeven\">\r\n\t\t\t\t\t\t\t<td>Messages</td>\r\n\t\t\t\t\t\t\t<td id=\"logmsg");
        out.print(i);
        out.write('"');
        out.write('>');
        out.print(msgs);
        out.write(
            "</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logodd\">\r\n\t\t\t\t\t\t\t<td>Roster</td>\r\n\t\t\t\t\t\t\t<td id=\"logroster");
        out.print(i);
        out.write('"');
        out.write('>');
        out.print(rosters);
        out.write(
            "</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logeven\">\r\n\t\t\t\t\t\t\t<td>Presence</td>\r\n\t\t\t\t\t\t\t<td id=\"logpresence");
        out.print(i);
        out.write('"');
        out.write('>');
        out.print(presences);
        out.write(
            "</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr id=\"logodd\">\r\n\t\t\t\t\t\t\t<td><span style=\"font-weight: bold;\">Total:</span></td>\r\n\t\t\t\t\t\t\t<td><span style=\"font-weight: bold;\">");
        out.print(iqs + msgs + rosters + presences);
        out.write(
            "</span></td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</tbody>\r\n\t\t\t\t</table>\r\n\r\n\t\t\t</div>\r\n\r\n\r\n\t\t\t");

        ++i;
      }

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

      if (!gatewayFound) {

        out.write(
            "\r\n\t\t\t<span style=\"font-weight: bold\">No connected external gateway components found.</span>\r\n\t\t\t");
      }

      out.write(
          "\r\n\t\t</div>\r\n\t\t\r\n\t\t\r\n<div class=\"jive-contentBoxHeader\">General Options</div>\r\n<div class=\"jive-contentBox\">\r\n   <table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n   <tbody>\r\n   <tr valign=\"top\">\r\n       <td width=\"100%\">\r\n           <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n           <tbody>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><input type=\"checkbox\" name=\"persistentEnabled\" id=\"GO1\" value=\"true\"\r\n\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.persistent", false)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td><label for=\"GO1\">Enable persistent Roster</label></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td />\r\n\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">When Persistent-Roster is enabled, contacts will be saved to database and\r\n\t\t\t\t\tno contacts will be deleted\tby GoJara automatically.<br>\t\t\t\t\t\r\n\t\t\t\t\tWhen Persistent-Roster is disabled, contacts will not be saved to database and \r\n\t\t\t\t\tGoJara will automatically delete all Legacy-RosterItems from the OF-Roster of a User upon logout.<br>Enable this if you want to store Gateway contacts in DB. </td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><input type=\"checkbox\" name=\"mucFilter\" id=\"GO2\" value=\"true\"\r\n\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.mucFilter", false)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td><label for=\"GO2\">Only allow internal Jabber Conferences</label></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td />\r\n\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">Spectrum might add MUC(Multi User Chat) to supported features\r\n\t\t\t\t\t of some Transports. If this should not be allowed, because only internal Jabber Conferences should be used, GoJara\r\n\t\t\t\t\t can remove these.</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><input type=\"checkbox\" name=\"ignoreSubdomains\" id=\"GO3\" value=\"true\"\r\n\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.ignoreSubdomains", true)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td><label for=\"GO2\">Do not add Subdomains to Roster</label></td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td />\r\n\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">If you do not want the gateway itself to show up as a contact on your roster,\r\n\t\t\t\t\tenable this (only happens on registration).\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\r\n           </tbody>\r\n           </table>\r\n       </td>\r\n   </tr>\r\n   </tbody>\r\n   </table>\r\n</div>\r\n\r\n\t\t<br /> <br />\r\n\t\t<div class=\"jive-contentBoxHeader\">Client specific options</div>\r\n\t\t<div class=\"jive-contentBox\">\r\n\t\t\t<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" width=\"100%\">\r\n\t\t\t\t<tbody>\r\n\t\t\t\t\t<tr valign=\"top\">\r\n\t\t\t\t\t\t<td width=\"1%\" nowrap class=\"c1\">Spark:</td>\r\n\t\t\t\t\t\t<td width=\"99%\">\r\n\t\t\t\t\t\t\t<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\t\t\t\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td><input type=\"checkbox\" name=\"sparkDiscoInfo\" id=\"SDI\" value=\"true\"\r\n\t\t\t\t\t\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.sparkDiscoInfo", false)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td><label for=\"SDI\"> Support jabber:iq:registered feature</label></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td />\r\n\t\t\t\t\t\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">If you use Spark clients within your network, it\r\n\t\t\t\t\t\t\t\t\t\t\tmight be necessary to modify the service discovery packets between Spark and the external component. If you\r\n\t\t\t\t\t\t\t\t\t\t\tcheck this RemoteRoster will add the feature \"jabber:iq:registered\" to the disco#info to indicate that the\r\n\t\t\t\t\t\t\t\t\t\t\tClient is registered with the external component.</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td><input type=\"checkbox\" name=\"iqLastFilter\" id=\"SDI2\" value=\"true\"\r\n\t\t\t\t\t\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.iqLastFilter", false)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td><label for=\"SDI\">Reply to jabber:iq:last </label></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td />\r\n\t\t\t\t\t\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">Some clients try to check how long a contact is already offline.\r\n\t\t\t\t\t\t\t\t\t\t This feature is not supported by spectrum so it won't response to this IQ stanza. To prevent the client from waiting\r\n\t\t\t\t\t\t\t\t\t\t for a response we could answer with a service-unavailable message as described in XEP-12.</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td><input type=\"checkbox\" name=\"blockPresences\" id=\"SDI3\" value=\"true\"\r\n\t\t\t\t\t\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.blockPresences", true)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td><label for=\"SDI\">Block presence pushing to rosterItems except gateway</label></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td />\r\n\t\t\t\t\t\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">Openfire automatically pushes Presences to every Item on your Roster.\r\n\t\t\t\t\t\t\t\t\t\tFor Spark, this means that roster items which are imported through gateway will trigger automatic login, even if you configured\r\n\t\t\t\t\t\t\t\t\t\tSpark to not connect to these gateways on Startup.<br>\r\n\t\t\t\t\t\t\t\t\t\tBlock Presences if you use Spark and do not want to autoconnect.</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t\t\t</table>\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t\t<tr valign=\"top\">\r\n\t\t\t\t\t\t<td width=\"1%\" nowrap class=\"c1\">Gajim:</td>\r\n\t\t\t\t\t\t<td width=\"99%\">\r\n\t\t\t\t\t\t\t<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\r\n\t\t\t\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td><input type=\"checkbox\" name=\"gajimBroadcast\" id=\"gajimBroadcast\" value=\"true\"\r\n\t\t\t\t\t\t\t\t\t\t\t");
      out.print(
          JiveGlobals.getBooleanProperty("plugin.remoteroster.gajimBroadcast", false)
              ? "checked=\"checked\""
              : "");
      out.write(
          " />\r\n\t\t\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t\t\t<td><label for=\"gajimBroadcast\">Push available presence on startup</label></td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<td />\r\n\t\t\t\t\t\t\t\t\t\t<td align=\"left\" style=\"font-size: -3; color: grey\">Enable this if Gojara should push available presences to\r\n\t\t\t\t\t\t\t\t\t\ttransports from your roster on startup. If disabled, you may have to manually send an available presence to the specific \r\n\t\t\t\t\t\t\t\t\t\ttransport to connect to it.<br>Not needed if you add Subdomains to roster + disabled presence blocking.</td>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t\t\t</table>\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</tbody>\r\n\t\t\t</table>\r\n\t\t</div>\r\n\r\n\r\n\t\t<input type=\"submit\" name=\"save\" value=\"Save Settings\" />\r\n\t</form>\r\n\r\n</body>\r\n</html>\r\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 {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
コード例 #25
0
ファイル: AddProjectServlet.java プロジェクト: ideaesb/paws
  private void setProjectBean(HttpServletRequest request) {
    pb.setProjectname(request.getParameter("projectname"));
    pb.setTraining(request.getParameter("training"));
    pb.setEducation(request.getParameter("education"));
    pb.setOutreach(request.getParameter("outreach"));
    pb.setObserving(request.getParameter("observing"));
    pb.setDataservices(request.getParameter("dataservices"));
    pb.setVariability(request.getParameter("variability"));
    pb.setOperational(request.getParameter("operational"));
    pb.setResearch(request.getParameter("research"));
    pb.setVhistorical(request.getParameter("vhistorical"));
    pb.setVprojections(request.getParameter("vprojections"));
    pb.setAsurface(request.getParameter("asurface"));
    pb.setUpperair(request.getParameter("upperair"));
    pb.setComposition(request.getParameter("composition"));
    pb.setOsurface(request.getParameter("osurface"));
    pb.setSubsurface(request.getParameter("subsurface"));
    pb.setTerrestrial(request.getParameter("terrestrial"));
    pb.setSeasonal(request.getParameter("seasonal"));
    pb.setAnnual(request.getParameter("annual"));
    pb.setDecadal(request.getParameter("decadal"));
    pb.setEffect(request.getParameter("effect"));
    pb.setImpacts(request.getParameter("impacts"));
    pb.setEhistorical(request.getParameter("ehistorical"));
    pb.setEprojections(request.getParameter("eprojections"));
    pb.setAdaptation(request.getParameter("adaptation"));
    pb.setPhs(request.getParameter("phs"));
    pb.setFwr(request.getParameter("fwr"));
    pb.setEne(request.getParameter("ene"));
    pb.setTcc(request.getParameter("tcc"));
    pb.setCpd(request.getParameter("cpd"));
    pb.setScr(request.getParameter("scr"));
    pb.setAfi(request.getParameter("afi"));
    pb.setRat(request.getParameter("rat"));
    pb.setEco(request.getParameter("eco"));
    pb.setOth(request.getParameter("oth"));
    pb.setGuidance(request.getParameter("guidance"));
    pb.setGvariability(request.getParameter("gvariability"));
    pb.setGeffects(request.getParameter("geffects"));
    pb.setApps(request.getParameter("apps"));
    pb.setAvariability(request.getParameter("avariability"));
    pb.setAeffects(request.getParameter("aeffects"));
    pb.setPolicies(request.getParameter("policies"));
    pb.setAssessment(request.getParameter("assessment"));
    pb.setFresh(request.getParameter("fresh"));
    pb.setCoastal(request.getParameter("coastal"));
    pb.setMarine(request.getParameter("marine"));
    pb.setCentral(request.getParameter("central"));
    pb.setHawaii(request.getParameter("hawaii"));
    pb.setBig(request.getParameter("big"));
    pb.setMaui(request.getParameter("maui"));
    pb.setOahu(request.getParameter("oahu"));
    pb.setKauai(request.getParameter("kauai"));
    pb.setHother(request.getParameter("hother"));
    pb.setWestern(request.getParameter("western"));
    pb.setGuam(request.getParameter("guam"));
    pb.setCnmi(request.getParameter("cnmi"));
    pb.setFsm(request.getParameter("fsm"));
    pb.setRmi(request.getParameter("rmi"));
    pb.setPalau(request.getParameter("palau"));
    pb.setWother(request.getParameter("wother"));
    pb.setSouth(request.getParameter("south"));
    pb.setAsam(request.getParameter("asam"));
    pb.setSamoa(request.getParameter("samoa"));
    pb.setTonga(request.getParameter("tonga"));
    pb.setFiji(request.getParameter("fiji"));
    pb.setOz(request.getParameter("oz"));
    pb.setNz(request.getParameter("nz"));
    pb.setFp(request.getParameter("fp"));
    pb.setSother(request.getParameter("sother"));
    pb.setOtherregions(request.getParameter("otherregions"));
    pb.setStatus(request.getParameter("status"));
    pb.setLeadagencies(request.getParameterValues("leadagencies"));
    pb.setPartneragencies(request.getParameterValues("partneragencies"));
    pb.setProjectdescription(request.getParameter("projectdescription"));
    pb.setWorksheetfilename(request.getParameter("worksheetfilename"));
    pb.setTag(request.getParameter("tag"));
    pb.setCode(request.getParameter("code"));

    // separately handle contacts, email until figure out a better more efficient
    // way of passing names, emails as arrays to be picked up by request.getParameterValues...

    String[] contacts = new String[3];
    String[] emails = new String[3];

    contacts[0] = StringUtils.trimToEmpty(request.getParameter("contact1"));
    // System.out.println("AddProjectServlet.setProjectBean contacts[0] set to " + contacts[0] );
    contacts[1] = StringUtils.trimToEmpty(request.getParameter("contact2"));
    // System.out.println("AddProjectServlet.setProjectBean contacts[1] set to " + contacts[1] );
    contacts[2] = StringUtils.trimToEmpty(request.getParameter("contact3"));
    // System.out.println("AddProjectServlet.setProjectBean contacts[2] set to " + contacts[2] );

    emails[0] = StringUtils.trimToEmpty(request.getParameter("email1"));
    // System.out.println("AddProjectServlet.setProjectBean emails[0] set to " + emails[0] );
    emails[1] = StringUtils.trimToEmpty(request.getParameter("email2"));
    // System.out.println("AddProjectServlet.setProjectBean emails[1] set to " + emails[1] );
    emails[2] = StringUtils.trimToEmpty(request.getParameter("email3"));
    // System.out.println("AddProjectServlet.setProjectBean emails[2] set to " + emails[2] );

    pb.setContactName(contacts);
    pb.setEmailsAddress(emails);
    pb.setContactList();
    // System.out.println("Project " + pb.getProjectnumber() + ", " + pb.getProjectname() + "
    // contacts and emails have been set from request parameters " );
    // System.out.println("Contacts = " + pb.getContacts(""));

  }
コード例 #26
0
  /**
   * Show details about the request
   *
   * @param servlet used to get teh servlet context, may be null
   * @param req the request
   * @return string showing the details of the request.
   */
  public static String showRequestDetail(HttpServlet servlet, HttpServletRequest req) {
    StringBuilder sbuff = new StringBuilder();

    sbuff.append("Request Info\n");
    sbuff.append(" req.getServerName(): ").append(req.getServerName()).append("\n");
    sbuff.append(" req.getServerPort(): ").append(req.getServerPort()).append("\n");
    sbuff.append(" req.getContextPath:").append(req.getContextPath()).append("\n");
    sbuff.append(" req.getServletPath:").append(req.getServletPath()).append("\n");
    sbuff.append(" req.getPathInfo:").append(req.getPathInfo()).append("\n");
    sbuff.append(" req.getQueryString:").append(req.getQueryString()).append("\n");
    sbuff
        .append(" getQueryStringDecoded:")
        .append(EscapeStrings.urlDecode(req.getQueryString()))
        .append("\n");
    /*try {
      sbuff.append(" getQueryStringDecoded:").append(URLDecoder.decode(req.getQueryString(), "UTF-8")).append("\n");
    } catch (UnsupportedEncodingException e1) {
      e1.printStackTrace();
    }*/
    sbuff.append(" req.getRequestURI:").append(req.getRequestURI()).append("\n");
    sbuff.append(" getRequestBase:").append(getRequestBase(req)).append("\n");
    sbuff.append(" getRequestServer:").append(getRequestServer(req)).append("\n");
    sbuff.append(" getRequest:").append(getRequest(req)).append("\n");
    sbuff.append("\n");

    sbuff.append(" req.getPathTranslated:").append(req.getPathTranslated()).append("\n");
    String path = req.getPathTranslated();
    if ((path != null) && (servlet != null)) {
      ServletContext context = servlet.getServletContext();
      sbuff.append(" getMimeType:").append(context.getMimeType(path)).append("\n");
    }
    sbuff.append("\n");
    sbuff.append(" req.getScheme:").append(req.getScheme()).append("\n");
    sbuff.append(" req.getProtocol:").append(req.getProtocol()).append("\n");
    sbuff.append(" req.getMethod:").append(req.getMethod()).append("\n");
    sbuff.append("\n");
    sbuff.append(" req.getContentType:").append(req.getContentType()).append("\n");
    sbuff.append(" req.getContentLength:").append(req.getContentLength()).append("\n");

    sbuff.append(" req.getRemoteAddr():").append(req.getRemoteAddr());
    try {
      sbuff
          .append(" getRemoteHost():")
          .append(java.net.InetAddress.getByName(req.getRemoteHost()).getHostName())
          .append("\n");
    } catch (java.net.UnknownHostException e) {
      sbuff.append(" getRemoteHost():").append(e.getMessage()).append("\n");
    }
    sbuff.append(" getRemoteUser():").append(req.getRemoteUser()).append("\n");

    sbuff.append("\n");
    sbuff.append("Request Parameters:\n");
    Enumeration params = req.getParameterNames();
    while (params.hasMoreElements()) {
      String name = (String) params.nextElement();
      String values[] = req.getParameterValues(name);
      if (values != null) {
        for (int i = 0; i < values.length; i++) {
          sbuff
              .append("  ")
              .append(name)
              .append("  (")
              .append(i)
              .append("): ")
              .append(values[i])
              .append("\n");
        }
      }
    }
    sbuff.append("\n");

    sbuff.append("Request Headers:\n");
    Enumeration names = req.getHeaderNames();
    while (names.hasMoreElements()) {
      String name = (String) names.nextElement();
      Enumeration values = req.getHeaders(name); // support multiple values
      if (values != null) {
        while (values.hasMoreElements()) {
          String value = (String) values.nextElement();
          sbuff.append("  ").append(name).append(": ").append(value).append("\n");
        }
      }
    }
    sbuff.append(" ------------------\n");

    return sbuff.toString();
  }