[thelist] Java 1.02 / URLConnections / LiveConnect

Michael Pemberton mpember at phreaker.net
Thu Jul 12 10:51:36 CDT 2001


I am in the process of putting together a dhtml api that uses java /
activex / xcom to transfer data to / from the server.

I use liveconnect in NS4 and can't seem to get a POST request to work.
If I remove the part that sends data, it works.  If I place the code
back in, it just returns a null value instead of the url's contents.

Here's the code I am testing:
----------------------------------------------------------------
// URL of CGI-Bin script.
url = new java.net.URL (FileIO.urlToAbs("url_js.html"));
urlConn = url.openConnection();
urlConn.setDoInput (true); // <-- this is supposed to make sending info
possible
urlConn.setDoOutput (true);
urlConn.setUseCaches (false);
urlConn.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
var printout = new java.io.DataOutputStream(urlConn.getOutputStream());
var content = "name=" + escape("Buford Early") +
    "&email=" + escape("buford at known-space.com");
alert(content);
printout.writeBytes(content);
printout.flush();
printout.close();

// Get response data.
input=new java.io.DataInputStream(urlConn.getInputStream());
var str="", tmpStr="";
while(tmpStr=input.readLine()) str += tmpStr + "\n";
input.close ();
alert(str);
----------------------------------------------------------------

Any comments / help would be greatly appreciated.  Thanx.
--
Michael Pemberton
mpember at phreaker.net
ICQ: 12107010







More information about the thelist mailing list