Wednesday, 15 January 2014

java - How to pass login credentials to asp server from android app -



java - How to pass login credentials to asp server from android app -

from researching have found out, can send info server using httppost have.

httpclient client = new defaulthttpclient(); httppost post = new httppost("https://portal.sibt.nsw.edu.au/default.asp");

i have 2 edittext fields hold userid , password, , button login.

edittext id ; edittext pword ; button login ; list<namevaluepair> namevaluepair = new arraylist<namevaluepair>(2); namevaluepair.add(new basicnamevaluepair("userid", id.gettext().tostring())); namevaluepair.add(new basicnamevaluepair("password", pword.gettext().tostring())); post.setentity(new urlencodedformentity(namevaluepair));//already within try/catch() block new getresponse().execute() // in asynctask public abstract class getresponse extends asynctask<void, void, void>{ public string doinbackground(){ seek { httpresonse response = client.execute(post); string responsecontent = entityutils.tostring(response.getentity()); log.d("response string", responsecontent); }/...

now in logcat see html of "https://portal.sibt.nsw.edu.au/default.asp", however, when checking entity system.out.println(post.getentity()); "org.apache.http.client.entity.urlencodedformentity@41237c10" not getting page in response supposed to, page after login, instead html of "post". doing wrong.

note: compiling in 4.1.2

you need content consume message:

inputstream in = entity.getcontent();

then can read inputstream

java android

No comments:

Post a Comment