Reputation: 11097
Hello All I am sending signup data to server but when line of my code dos = new DataOutputStream (urlConn.getOutputStream()); encounters it throws an IOException "Permission Denied" I have used the same code for another server before also and that time it worked fine. I am not getting what is problem with this plz Help me MY CODE IS try {
URL url;
// URLConnection urlConn; DataOutputStream dos; DataInputStream dis;
/---------------------THIS IS ADDRESS LINK WHERE WE HAVE TO SEND DATA------------***/
String server_url_string = "http:----"signup.php";
url = new URL(server_url_string);
// urlConn = url.openConnection(); HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
urlConn.setDoInput(true);
urlConn.setDoOutput(true);
urlConn.setUseCaches(false);
urlConn.setRequestProperty ("METHOD", "POST");
dos = new DataOutputStream (urlConn.getOutputStream());
/*-------------PREPARING STRING OF DATA TO BE SEND ON SERVER------------------/
String data_to_be_send = "signupdata=first_name="+first_name_str+":"+
"oomplast_name="+last_name_str+":"+
"oomppassword="+password_str+":"+
"oompprimary_email="+email_str;
Log.i("SERVER URL ",server_url_string);
Log.i("SENDING DATA ",data_to_be_send);
dos.writeBytes(data_to_be_send);
dos.flush();
dos.close();
/** ------ The server responds by saying "Registration successfull." or "particular message or Invalid Data" -----*/
/-------------------RETRIEVING MESSAGE CAME FROM SERVER----------------/
dis = new DataInputStream(urlConn.getInputStream());
Log.i(" PASSED ","dis INITIALIZED");
server_message = dis.readLine();
Log.i(" PASSED ","server_message INITIALIZED");
Log.i("SERVER RESPONSE",server_message+"");
}
catch (MalformedURLException mue)
{
Log.i("EXCEPTION GENERATED MalformedURLException", " "+mue.getMessage());
}
catch (IOException ioe)
{
Log.i("EXCEPTION GENERATED IOException ", " "+ioe.getMessage());
}
Upvotes: 0
Views: 174
Reputation: 10948
Make sure you have <uses-permission android:name="android.permission.INTERNET"/>
in your Android Manifest.
Upvotes: 1