Question: I have a piece of code which removes selective parameters from the url

```
    public String stripAndApplyTags(final List<NameValuePair> tags, final String url) throws URISyntaxException {
    final URIBuilder existingLinkUrl = new URIBuilder(url);
    List<NameValuePair> existingTags = existingLinkUrl.getQueryParams();
    List<NameValuePair> newTags = new ArrayList<>();

    for (Iterator<NameValuePair> queryParameterItr = existingTags.iterator(); queryParameterItr.hasNext();) {
        NameValuePair queryParameter = queryParameterItr.next();
        if (!queryParameter.getName().equals("test")) {
            newTags.add(queryParameter);
        }
    }
    newTags.addAll(tags);
    return existingLinkUrl.clearParameters().setParameters(newTags).build().toString();
}

```

But the problem is if my url is of this form at - 

```
https://somexyzz/test=s9u_simh_gw_i1?ie=UTF8

```

Is there a way for me to remove this additional test tag using URIBuilder?

Answer: 
> 
> *Is there a way for me to remove this additional test tag using
>  URIBuilder?*
> 
> 
> 

yes, you can create the [URL](https://docs.oracle.com/javase/8/docs/api/java/net/URL.html) object and get the required info:

```
public static void main(String[] args) throws ParseException, MalformedURLException {
    String foo = "https://somexyzz/test=s9u_simh_gw_i1?ie=UTF8";
    URL myUrl = new URL(foo);
    System.out.println("protocol = " + myUrl.getProtocol());
    System.out.println("authority = " + myUrl.getAuthority());
    System.out.println("host = " + myUrl.getHost());
    System.out.println("port = " + myUrl.getPort());
    System.out.println("path = " + myUrl.getPath());
    System.out.println("query = " + myUrl.getQuery());
    System.out.println("filename = " + myUrl.getFile());
    System.out.println("ref = " + myUrl.getRef());
}

```
This will remove all queryParams from your url

```
URIBuilder b = new URIBuilder(url);
b.removeQuery();

```