html - Logging into Website Using Java -



html - Logging into Website Using Java -

first of yes know there 1000000 questions inquire same thing none of answers working. using next code:

url objtest = new url("http://rccpdems01/ems/login.php"); httpurlconnection con = (httpurlconnection) objtest.openconnection(); con.setrequestmethod("post"); string datas = "userid=g434326&psword=testpass"; con.setdooutput(true); dataoutputstream wr = new dataoutputstream(con.getoutputstream()); wr.writebytes(datas); wr.flush(); wr.close(); bufferedreader in = new bufferedreader(new inputstreamreader(con.getinputstream())); string inputline; while ((inputline = in.readline()) != null) system.out.println(inputline); in.close();

however lines beingness returned makes seem nil happened on html form, no error message displayed if pass wrong input details, , if right ones next or "homepage" html code not returned.

why ? need activate button ? if how do here buttons details:

type="submit" name="btnlogin" value="login"

thanks ulrich

what returning next html code:

<html> <style type="text/css"> .m0 { font-weight: bold; font-family: arial; color: black; background-color: black; font-size: x-small;; } .m1 { font-weight: bold; font-family: arial; color: white; background-color: red; font-size: x-small; letter-spacing: normal; word-spacing: normal; width: 100%; border-top-style: double; border-right-style: double; border-bottom-style: double; border-left-style: double; }

i didn't post idea.

hi, ok found reply needed define login button pressed:

userid=g4737326&psword=uwwitest&btnlogin=login

now need figure out how post results gettig browser.

posting you're seeing returned helpful. without more information, can't tell whats wrong code, can suggest trying apache http client. question, might find form based login example helpful.

edit:

it sounds you're trying simulate button press. if case, not need scrap html page. need figure out url button press generating, , submit programmatically. need read header, , determine login cookie set. apache http client you.

java html website

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -