Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
    Bookmark Topic Watch Topic
  • New Topic

URL Object Not POSTing to Servlet  RSS feed

Mike London
Ranch Hand
Posts: 1441
  • Mark post as helpful
  • send pies
  • Report post to moderator
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();
OutputStreamWriter out = new OutputStreamWriter(
out.write("data=" + xmlData);


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
Ulf Dittmer
Posts: 42972
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not post the same question multiple times. Let's continue the discussion in this duplicate thread.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!