You need to use URLConnection to achieve this:
HTTP GET:
URLConnection connection = new URL(url + "?" + query).openConnection();
connection.setRequestProperty("Accept-Charset", charset);
InputStream response = connection.getInputStream();
Target URL's doGet() method will be called and the parameters will be available by HttpServletRequest#getParameter().
HTTP POST:
URLConnection connection = new URL(url).openConnection();
connection.setDoOutput(true); // Triggers POST.
connection.setRequestProperty("Accept-Charset", charset);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + charset);
try (OutputStream output = connection.getOutputStream()) {
output.write(query.getBytes(charset));
}
InputStream response = connection.getInputStream();
Target URL's doGet() method will be called and the parameters will be available by HttpServletRequest#getParameter().