code: public static String checkNull(String val) {
      if (val == null) {
        return null;
      }
  
      val = val.trim();
      if (val.length() == 0) {
        return null;
      }
  
      return val;
    }
docs: We get a lot of zero length (or all white space) strings in the web world.
  This will return null for a zero length.
  
  @param  val    String request parameter value
  @return String null for null or zero lengt val, val otherwise.