java - Display captcha in Jframe -
i want create application registration in java, want submit information website. experiment information registration(e.g username, password) submit request. want integrate captcha registration , want display on jframe , submit answer along side other data. have no idea how captcha image, , submit data. think use new recaptcha(where ask select foods). ideas how this?
edit: know how display image jlabel, able find way extract get image captcha session .now i'm wondering how send response.
to send response need session id server , clients answer send request server both of values
public void getmethod() throws ioexception { string useragent = "java/" + runtime.class.getpackage().getimplementationversion(); //the server need know "question" answering sent captha , sesion id //example random 1 need figure out how sesion id string captchasesionparam = "captchasesionid="; string captchasesionid = uuid.randomuuid().tostring(); //user has completed captha client side here answer string queryparam = "answer="; string answer = "blah blah answer"; string urlstring = "https://127.0.0.1/?" + queryparam + urlencoder.encode(answer, "utf-8") + "&" + captchasesionparam + urlencoder.encode(captchasesionid, "utf-8"); url url = new url(urlstring); //open https connection url httpurlconnection con = (httpurlconnection) url.openconnection(); //set request method con.setrequestmethod("get"); //set user agent our agent (by default believe 'java/version') con.setrequestproperty("user-agent", useragent); //print out debug info request method , url system.out.println(con.getrequestmethod() + " url : " + url); int responsecode = con.getresponsecode(); system.out.println("server response code: " + responsecode); try (bufferedreader in = new bufferedreader(new inputstreamreader(con.getinputstream(), "utf-8"));) { string line; list<string> lines = new arraylist<string>(); while ((line = in.readline()) != null) { lines.add(line); } //parse lines received server see if captcha (in)correct //print lines debug for(string l : lines) { system.out.println(l); } } }
Comments
Post a Comment