Exemplo n.º 1
0
 /**
  * Gathers the parameters in the request as a HTTP URL string. to form <code>requestParams</code>
  * String. 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 It also putsthe advice params in a separate
  * <code>policyAdviceList</code> String.
  *
  * @param request an HttpServletRequest object that contains the request the client has made of
  *     the servlet.
  */
 private void parseRequestParams(HttpServletRequest request) {
   StringBuffer adviceList = null;
   StringBuffer parameterString = new StringBuffer(100);
   for (Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) {
     String paramName = (String) e.nextElement();
     if (adviceParams.contains(paramName.toLowerCase())) {
       if (adviceList == null) {
         adviceList = new StringBuffer();
       } 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());
   }
   if (adviceList == null) {
     policyAdviceList = null;
   } else {
     policyAdviceList = adviceList.toString();
   }
   if (parameterString.length() > 0) {
     requestParams = (parameterString.deleteCharAt(0).toString());
   } else {
     requestParams = parameterString.toString();
   }
 }
Exemplo n.º 2
0
  private String getMessageTable(StringBuffer msg) {
    StringBuffer sb = new StringBuffer();

    if (msg.length() > 0) {
      // sb.append("<a href=\"javascript:clearmsgs()\">Clear Messages</a>");
      sb.append("<table class=\"msgbox\">");
      // sb.append("<tr><th>");
      // sb.append("<input type=\"submit\" value=\"Clear Messages\"
      // onclick=\"clearmsgs()\"></input>");
      // sb.append("</th></tr>");
      sb.append("<tr><td>");
      sb.append(msg.toString());
      sb.append("</td></tr>");
      sb.append("</table>");
    }
    return sb.toString();
  }
Exemplo n.º 3
0
  public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {

    String smsFrom = request.getParameter("From");
    String smsBody = request.getParameter("Body");
    String desc = null;
    String data = null;
    StringBuffer smsBuffer = new StringBuffer();
    smsBuffer.append(smsBody);
    for (int i = 0; i < smsBuffer.length(); i++) {
      if (smsBuffer.charAt(i) == '.') {
        desc = smsBuffer.substring(0, i);
        data = smsBuffer.substring(i);
      }
    }
    String x = "CALL smsInsert('" + smsFrom + "','" + desc + "','" + data + "')";
    new DB();
    try {
      DB.doU(x);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 4
0
  private int _writeHTML(PrintWriter out, int level, ReportData rd, int ndx)
      throws ReportException {
    RequestProperties reqState = rd.getRequestProperties();
    boolean isEMail = reqState.getEncodeEMailHTML();
    PrivateLabel privLabel = rd.getPrivateLabel();
    I18N i18n = privLabel.getI18N(ReportTable.class);

    out.print("<center>\n");
    out.print("<table cellspacing='0' cellpadding='0' border='0'>\n");

    /* report title row */
    {
      String rptTitle = rd.getReportTitle();
      out.print(
          "<tr><td colSpan='3'><H1 class=\"rptTitle\">"
              + FilterText(rptTitle)
              + "</H1></td></tr>\n");
    }

    /* report subtitle row */
    {
      out.print("<tr>\n");

      // "Refresh"
      out.print("<td>");
      StringBuffer linkSB_L = new StringBuffer();
      String refreshURL = (!isEMail && (ndx <= 0)) ? EncodeURL(reqState, rd.getRefreshURL()) : null;
      if (!StringTools.isBlank(refreshURL)) {
        String refreshDesc = i18n.getString("ReportTable.refreshReport", "Refresh");
        if (linkSB_L.length() > 0) {
          linkSB_L.append("&nbsp;&nbsp;");
        } // add space between links
        linkSB_L.append(
            "<a href='" + refreshURL + "' target='_self'>" + refreshDesc + "</a>"); // target='_top'
      }
      // ...
      if (linkSB_L.length() > 0) {
        out.print(linkSB_L.toString());
      } else {
        out.print("&nbsp;");
      }
      out.print("</td>\n");

      // Report subtitle
      out.print("<td width='100%'>");
      String rptSubtt = rd.getReportSubtitle();
      if (!StringTools.isBlank(rptSubtt)) {
        out.print("<H2 class=\"rptSubtitle\">" + FilterText(rptSubtt) + "</H2>");
      } else {
        out.print("&nbsp;");
      }
      out.print("</td>\n");

      // "Graph", "Map" links
      out.print("<td>");
      StringBuffer linkSB_R = new StringBuffer();
      String graphURL =
          (!isEMail && (ndx < 0) && rd.getSupportsGraphDisplay())
              ? EncodeURL(reqState, rd.getGraphURL())
              : null;
      if (!StringTools.isBlank(graphURL)) {
        MapDimension sz = rd.getGraphWindowSize();
        String desc = rd.getGraphLinkDescription();
        if (StringTools.isBlank(desc)) {
          desc = i18n.getString("ReportTable.displayGraph", "Graph");
        }
        if (linkSB_R.length() > 0) {
          linkSB_R.append("&nbsp;&nbsp;");
        } // add space between links
        linkSB_R.append(
            "<span class='spanLink' onclick=\"javascript:openResizableWindow('"
                + graphURL
                + "','ReportGraph',"
                + sz.getWidth()
                + ","
                + sz.getHeight()
                + ");\">"
                + desc
                + "</span>");
      }
      String mapURL =
          (!isEMail && (ndx < 0) && rd.getSupportsMapDisplay())
              ? EncodeURL(reqState, rd.getMapURL())
              : null;
      if (!StringTools.isBlank(mapURL)) {
        MapDimension sz = rd.getMapWindowSize();
        String desc = rd.getMapLinkDescription();
        if (StringTools.isBlank(desc)) {
          desc = i18n.getString("ReportTable.displayMap", "Map");
        }
        if (linkSB_R.length() > 0) {
          linkSB_R.append("&nbsp;&nbsp;");
        } // add space between links
        linkSB_R.append(
            "<span class='spanLink' onclick=\"javascript:openResizableWindow('"
                + mapURL
                + "','ReportMap',"
                + sz.getWidth()
                + ","
                + sz.getHeight()
                + ");\">"
                + desc
                + "</span>");
      }
      String kmlURL =
          (!isEMail
                  && (ndx < 0)
                  && rd.getSupportsKmlDisplay()
                  && privLabel.getBooleanProperty(
                      PrivateLabel.PROP_ReportDisplay_showGoogleKML, false))
              ? EncodeURL(reqState, rd.getKmlURL())
              : null;
      if (!StringTools.isBlank(kmlURL)) {
        String desc = rd.getKmlLinkDescription();
        if (StringTools.isBlank(desc)) {
          desc = i18n.getString("ReportTable.displayKML", "KML");
        }
        if (linkSB_R.length() > 0) {
          linkSB_R.append("&nbsp;&nbsp;");
        } // add space between links
        linkSB_R.append("<a href='" + kmlURL + "' target='_blank'>" + desc + "</a>");
      }
      // ...
      if (linkSB_R.length() > 0) {
        out.print(linkSB_R.toString());
      } else {
        out.print("&nbsp;");
      }
      out.print("</td>\n");

      out.print("</tr>\n");
    }

    /* start report */
    out.print("<tr>\n");
    out.print("<td colSpan='3'>\n");
    String tableClass =
        rd.getReportFactory().isTableSortable() ? CSS_CLASS_TABLE_SORT : CSS_CLASS_TABLE;
    out.print(
        "<table class='"
            + tableClass
            + "' width='100%' cellspacing='0' cellpadding='0' border='0'>\n");
    out.print("<!-- Report Header -->\n");
    this.rptHeader.writeHTML(out, level + 1, rd);
    out.print("<!-- Report Data -->\n");
    this.rptBody.writeHTML(out, level + 1, rd);
    out.print("</table>\n");
    out.print("</td>\n");
    out.print("</tr>\n");

    /* no/partial data indication */
    if (this.rptBody.getRecordCount() <= 0) {
      out.print("<tr>\n");
      out.print("<td colSpan='3'><H2 class=\"rptNoData\">");
      String t = i18n.getString("ReportTable.noData", "This report contains no data");
      out.print(FilterText(t));
      out.print("</H2></td>\n");
      out.print("</tr>\n");
    } else if (this.rptBody.isPartial()) {
      out.print("<tr>\n");
      out.print("<td colSpan='3'><H2 class=\"rptPartial\">");
      String t =
          i18n.getString(
              "ReportTable.partialData",
              "This report has reached it's record display limit and may only contain a portion of the possible data");
      out.print(FilterText(t));
      out.print("</H2></td>\n");
      out.print("</tr>\n");
    }

    out.print("</table>\n");
    out.print("</center>\n");
    return this.rptBody.getRecordCount();
  }
Exemplo n.º 5
0
  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());
  }
Exemplo n.º 6
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {

    response.reset();
    response.setContentType("text/plain");
    PrintWriter writer = response.getWriter();

    // Accumulate all the reasons this request might fail
    ServletException exception = null;
    StringBuffer sb = new StringBuffer();
    Object value = null;

    value = request.getAttribute("javax.servlet.error.exception");
    if (value == null) sb.append(" exception is missing/");
    else if (!(value instanceof org.apache.tester.TesterException)) {
      sb.append(" exception class is ");
      sb.append(value.getClass().getName());
      sb.append("/");
    } else {
      TesterException te = (TesterException) value;
      if (!"ErrorPage03 Threw Exception".equals(te.getMessage())) {
        sb.append(" exception message is ");
        sb.append(te.getMessage());
        sb.append("/");
      }
    }

    value = request.getAttribute("javax.servlet.error.exception_type");
    if (value == null) sb.append(" exception_type is missing/");
    else if (!(value instanceof Class)) {
      sb.append(" exception_type class is ");
      sb.append(value.getClass().getName());
      sb.append("/");
    } else {
      Class clazz = (Class) value;
      if (!"org.apache.tester.TesterException".equals(clazz.getName())) {
        sb.append(" exception_type class is ");
        sb.append(clazz.getName());
        sb.append("/");
      }
    }

    value = request.getAttribute("javax.servlet.error.message");
    if (value == null) sb.append(" message is missing/");
    else if (!(value instanceof String)) {
      sb.append(" message class is ");
      sb.append(value.getClass().getName());
      sb.append("/");
    } else {
      String message = (String) value;
      if (!"ErrorPage03 Threw Exception".equals(message)) {
        sb.append(" message is ");
        sb.append(message);
        sb.append("/");
      }
    }

    value = request.getAttribute("javax.servlet.error.request_uri");
    if (value == null) sb.append(" request_uri is missing/");
    else if (!(value instanceof String)) {
      sb.append(" request_uri class is ");
      sb.append(value.getClass().getName());
      sb.append("/");
    } else {
      String request_uri = (String) value;
      String test1 = request.getContextPath() + "/ErrorPage03";
      String test2 = request.getContextPath() + "/WrappedErrorPage03";
      if (!request_uri.equals(test1) && !request_uri.equals(test2)) {
        sb.append(" request_uri is ");
        sb.append(request_uri);
        sb.append("/");
      }
    }

    value = request.getAttribute("javax.servlet.error.servlet_name");
    if (value == null) sb.append(" servlet_name is missing/");
    else if (!(value instanceof String)) {
      sb.append(" servlet_name class is ");
      sb.append(value.getClass().getName());
      sb.append("/");
    } else {
      String servlet_name = (String) value;
      if (!"ErrorPage03".equals(servlet_name)) {
        sb.append(" servlet_name is ");
        sb.append(servlet_name);
        sb.append("/");
      }
    }

    // Report ultimate success or failure
    if (sb.length() < 1) writer.println("ErrorPage04 PASSED");
    else writer.println("ErrorPage04 FAILED -" + sb.toString());

    while (true) {
      String message = StaticLogger.read();
      if (message == null) break;
      writer.println(message);
    }
    StaticLogger.reset();
  }