hi,
i have used "GET" and it works just fine with HttpURLConnection.
make URL from server address, then cast the url.openConnection() to HttpURLConnection, then use that.
Brs,
teija
"HttpURLConnection" do not work in pjava?
2002-12-16, 07:32#2
I wish to make my pjava applicaton send data to servlet using
POST method. But when I compiled the applicaion, compiler said: "java.net.HttpURLConnection is abstract; cannot be instantiated". I wonder if I can use HttpURLConnection in Pjava app. If not, what other classes can I use to communicate with servlet.
Part of my program:
...
HttpURLConnection conn = null;
InputStream in = null;
OutputStream out = null;
String sentStr = "Request data to servlet";
String servletUrl = "http://127.0.0.1:8080/examples/servlet/MyServlet";
conn = new HttpURLConnection(servletUrl);
conn.setRequestMethod(POST);
out = conn.openOutputStream();
int requestLength = sentStr.length();
for (int i = 0; i < requestLength; ++i)
{
out.write(sentStr.charAt(i));
}
...