Hi,
Doh! This is driving me nuts.
Whats wroing with this please, it keeps just giving "Unexpected end of
file from server". Using the url+args in a browser is fine so its not
my setup, just this damn code!!
Also, come to think about it in this case I don't want *any* return
value from the cgi call, so do I really have to much about with the
return string at all?
private void transmitToPhone(String target, String message) {
try {
URL otaServerURL = new
URL("http://localhost:13013/cgi-bin/sendsms?target="+target+"&message="+message);
URLConnection uc=otaServerURL.openConnection();
uc.setDoInput(true);
uc.setDoOutput(true);
uc.setUseCaches(false);
String data = "target="+target+"&message="+message;
uc.setRequestProperty("Content-type","java/octet");
uc.setRequestProperty("Content-length",""+data.length());
DataOutputStream dos=new DataOutputStream(uc.getOutputStream());
dos.writeBytes(data);
dos.flush();
dos.close();
DataInputStream dis=new DataInputStream(uc.getInputStream());
String line;
while((line=dis.readLine()) != null){
System.out.println(line); // Don't really want this
}
dis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
Cheers!
<*> The instructions said "Windows 98 or better". So I installed Linux. <*>