import java.net.URI;
import org.apache.http.client.methods.CloseableHttpResponse;  
import org.apache.http.client.methods.HttpUriRequest; 
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.impl.client.CloseableHttpClient;  
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.apache.http.NameValuePair;  
import java.io.*;
import java.net.URLEncoder;
import java.net.URLDecoder;


public class URLTest {
    CloseableHttpClient httpclient;
    public static void main(String[] args){
        new URLTest().the_test("Sam&J=Smith");
    }
    public URLTest(){
    }

    public void the_test(String the_string){
        try {
            httpclient = HttpClients.createDefault(); 
            HttpUriRequest httpuri = RequestBuilder.get()
                                     .setUri(new URI("http://hoare.cs.umsl.edu/servlet/siegel/test2"))
                                      .addParameter("whoisit", the_string)
                                      .addParameter("whoisit1", URLEncoder.encode(the_string,"UTF-8"))
                                     .build();
            System.out.println(httpuri.getURI().toString());
            CloseableHttpResponse response = httpclient.execute(httpuri); 

            System.out.println(EntityUtils.toString(response.getEntity()));  
        } catch (Exception exc) {
            exc.printStackTrace();
        }
    }
}