Forums Register Login

URL Object Not POSTing to Servlet

+Pie Number of slices to send: Send
I'm trying to get a URL object to POST to a Servlet (the Servlet logic works), but with the URL attempt below, I'm not getting it to POST.

No errors in the Tomcat log.

Here's the basic logic (from a basic java class)....

// call a web service to get an XML String
String xmlData = ws.getData() // ws is connection to the web service.

---------------------------

// now, the part that doesn't seem to connect to the Servlet...

url = new URL ("myServletURL"); // actual http address would be inside the quotes

URLConnection connection = url.openConnection();
connection.setDoOutput(true);
OutputStreamWriter out = new OutputStreamWriter(
connection.getOutputStream());
out.write("data=" + xmlData);
out.close();

----------

The servlet is supposed to create a disk file given this XML string, but the URL connection doesn't appear to work as no disk file gets created.

The same logic in .NET (using their URL equivalent logic) works fine.

----------

Any ideas what I'm missing?

Thanks in advance!!!

-- mike
+Pie Number of slices to send: Send
Please do not post the same question multiple times. Let's continue the discussion in this duplicate thread.
I'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


Reply locked
This thread has been viewed 783 times.
Similar Threads
Occasional Connection Reset (IO Exception) Errors when POSTing to Servlet
DELETE http request in HttpURLConnection....
javax.net.ssl.SSLException: untrusted server cert chain
need help on Java.NIO
Writing text files on a webserver
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 22:46:10.