posted 20 years ago
...this is what I use as a client that 'tunnels' into a listening servlet, hope it helps:
java.net.URL url = new java.net.URL(your_target_url_string);
java.net.URLConnection con = url.openConnection();
con.setUseCaches(false);
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
DataOutputStream out = new DataOutputStream(con.getOutputStream());
out.write(your_string_to_send.getBytes()); // WRITE to the site
out.flush();
BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(con.getInputStream()));
StringBuffer sb = new StringBuffer();
while ((inputLine = bufferedreader.readLine()) != null) {
sb.append(inputLine); // READ from the site
}
I shoulda been a rock star.