问题
this is my client side code- byte[] buffer= out.toByteArray();
String ba1=Base64.encodeBytes(buffer);
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("image",ba1));
nameValuePairs.add(new BasicNameValuePair("name",fbName));
nameValuePairs.add(new BasicNameValuePair("gender",fbGender));
and the i call method for http post-
public void getServerData(ArrayList<NameValuePair> nameValuePairs)
throws JSONException, ClientProtocolException, IOException {
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new
HttpPost(SERVER_URL);
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
}catch(Exception e){
Log.e("log_tag", "Error in http connection "+e.toString());
}
and the server side code onto servlet- byte[] image=Base64.decode("image"); BuffredArray img = ImageIO.read(new ByteArrayInputStream(image)); But the image hear is null????
on the servlet page i want to recieve those parameters one image i.e byte[] and two strings ???i dont know if it is possible to post data like this one image and two strings..but experimenting with only image first i am geting Exception java.lang.NullPointerException at java.io.ByteArrayInputStream.(ByteArrayInputStream.java:106)
来源:https://stackoverflow.com/questions/14379315/unable-to-get-values-seding-from-client-to-servlet-using-base64