Example #1
0
 /**
  * Get a parameter from a ServletRequest. Return null if the parameter contains only white spaces.
  */
 public static String getParameter(ServletRequest request, String name) {
   String s = request.getParameter(name);
   if (s == null) {
     return null;
   }
   s = s.trim();
   return s.length() == 0 ? null : s;
 }
  public void service(ServletRequest request, ServletResponse response)
      throws ServletException, IOException {

    // Get print writer.
    PrintWriter pw = response.getWriter();

    // Get enumeration of parameter names.
    Enumeration e = request.getParameterNames();

    // Display parameter names and values.
    while (e.hasMoreElements()) {
      String pname = (String) e.nextElement();
      pw.print(pname + " = ");
      String pvalue = request.getParameter(pname);
      pw.println(pvalue);
    }
    pw.close();
  }
  /**
   * @param req Request.
   * @return Command.
   */
  @Nullable
  GridRestCommand command(ServletRequest req) {
    String cmd = req.getParameter("cmd");

    return cmd == null ? null : GridRestCommand.fromKey(cmd.toLowerCase());
  }