public static String removeFromQueryString(String queryString,String matching) throws UnsupportedEncodingException {
  if (queryString == null) {
    return null;
  }
  StringBuffer resultQStr=new StringBuffer();
  for (  String pair : queryString.split("&")) {
    int eq=pair.indexOf("=");
    String key=null;
    if (eq < 0) {
      key=URLDecoder.decode(pair,UTF8_ENCODING);
    }
 else {
      key=URLDecoder.decode(pair.substring(0,eq),UTF8_ENCODING);
    }
    if (!key.equalsIgnoreCase(matching)) {
      if (resultQStr.length() > 0) {
        resultQStr.append("&");
      }
      resultQStr.append(pair);
    }
  }
  return resultQStr.toString();
}

public static String removeFromQueryString ( String queryString , String matching ) throws UnsupportedEncodingException { if ( queryString == null ) { return null ; } StringBuffer resultQStr = new StringBuffer ( ) ; for ( String pair : queryString . split ( "&" ) ) { int eq = pair . indexOf ( "=" ) ; String key = null ; if ( eq < 0 ) { key = URLDecoder . decode ( pair , UTF8_ENCODING ) ; } else { key = URLDecoder . decode ( pair . substring ( 0 , eq ) , UTF8_ENCODING ) ; } if ( ! key . equalsIgnoreCase ( matching ) ) { if ( resultQStr . length ( ) > 0 ) { resultQStr . append ( "&" ) ; } resultQStr . append ( pair ) ; } } return resultQStr . toString ( ) ; }
if matching key exists in the query string , removes it
