Hi, Guys
Facing a small problem, I want to know two things, Either i am going in the
right direction ? Second why i have these two syntax error, See below the
exact line.
1. *Syntax error on token ";", { expected after this token*
*2. **Error: Syntax error, insert "}" to complete ClassBody*
*
*
*Note I am beginner plz donot mind if i am doing some foolish mistake :-)
Thanks in advance*
here is my simple PHP code.
******************************************************
<?php
echo "param1 value: ".$_POST['parameterName1']."\n";
echo "param2 value: ".$_POST['parameterName2']."\n";
echo "Your post was successfully sent";
?>
**********************************************************
Now here come my Java code
//all Required imports and package
public class http_client extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
HttpPost httppost;
HttpClient httpclient;
// List with arameters and their values
List<NameValuePair> nameValuePairs;
String serverResponsePhrase;
int serverStatusCode;
String bytesSent; *<<<<<<< Syntax error on token ";", { expected after
this token*
httppost = new HttpPost(serverURL);
httpclient = new DefaultHttpClient();
nameValuePairs = new ArrayList<NameValuePair>(2);
// Adding parameters to send to the HTTP server.
nameValuePairs.add(new BasicNameValuePair(parameterName1, value1));
nameValuePairs.add(new BasicNameValuePair(parameterName2, value2));
// Send POST message with given parameters to the HTTP server.
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
InputStream is = response.getEntity().getContent();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(20);
int current = 0;
while((current = bis.read()) != -1)
{
baf.append((byte)current);
}
bytesSent = new String(baf.toByteArray());
// Response from the server
serverResponsePhrase = response.getStatusLine().getReasonPhrase();
serverStatusCode = response.getStatusLine().getStatusCode();
// for receiving response from the server
Toast.makeText(getBaseContext(),
bytesSent,
Toast.LENGTH_SHORT).show();
}
catch (Exception e) {
// Exception handling
}
} *<<<<<<< Error: Syntax error, insert "}" to complete ClassBody*
--
Atif
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en