Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Post data to a server and get response

Post data to a server and get response

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Post data to a server and get response

Postby manish » Mon Jun 01, 2009 8:22 am

Hi,

I want to post some data on the server and get response. Please share some example of this.
manish
Junior Developer
Junior Developer
 
Posts: 21
Joined: Thu Feb 05, 2009 1:06 pm

Top

Re: Post data to a server and get response

Postby manish » Thu Jun 04, 2009 12:28 pm

Hi,

I am able to get data using the following code:
private InputStream OpenHttpConnection(String urlString)
throws IOException
{
InputStream in = null;
int response = -1;

URL url = new URL(urlString);
URLConnection conn = url.openConnection();

if (!(conn instanceof HttpURLConnection))
throw new IOException("Not an HTTP connection");

try{
HttpURLConnection httpConn = (HttpURLConnection) conn;
httpConn.setAllowUserInteraction(false);
httpConn.setInstanceFollowRedirects(true);
httpConn.setRequestMethod("GET");
httpConn.connect();

response = httpConn.getResponseCode();
if (response == HttpURLConnection.HTTP_OK) {
in = httpConn.getInputStream();
}
}
catch (Exception ex)
{
throw new IOException("Error connecting");
}
return in;
}

but I am not able to post data and then get response. I have found a piece to post the data but I am not able to extract the response send by the server.

HttpClient httpClient = new DefaultHttpClient();
HttpPost postMethod = new HttpPost(mUrl);
try {
// prepare parameters
HttpParams params = new BasicHttpParams();
params.setParameter("locationJSON", mLocationJSON.toString());
postMethod.setParams(params);
HttpResponse response =httpClient.execute(postMethod);

Please help me.

manish wrote:Hi,

I want to post some data on the server and get response. Please share some example of this.
manish
Junior Developer
Junior Developer
 
Posts: 21
Joined: Thu Feb 05, 2009 1:06 pm

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 3 guests