send huge data from Java servlet to Android application -
i want sent large data server client, server tomcat java , client android application , working servlets
server servlet
protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { servletoutputstream out = response.getoutputstream(); celldatabase cdb = new celldatabase(); string[] cells = cdb.getallcells(); (int = 0; < cells.length; i++) out.write(cells[i].getbytes()); out.flush(); }
my question : how can got data on android , because didn't find like
response.getoutputstream();
android
httpclient client = new defaulthttpclient(); website = new uri( "http://10.0.2.2:8080/localizedbasedcomptitionserver/getcells"); httppost request = new httppost(); request.seturi(website); httpresponse response = client.execute(request);
this may you
public static string getdata(string url) { system.out.println("connecting service url : " + url); inputstream = null; string result = ""; // http post try { httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(url); httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); = entity.getcontent(); } catch (exception e) { } // convert response string try { bufferedreader reader = new bufferedreader(new inputstreamreader(is, "iso-8859-1"), 8); stringbuilder sb = new stringbuilder(); string line = null; while ((line = reader.readline()) != null) { sb.append(line + "\n"); } is.close(); result = sb.tostring(); } catch (exception e) { } return result; }
Comments
Post a Comment