java - Sending http request through an open Browser -
i'm trying values out of response of call our server @ work. problem i'm facing if send same request through browser, preferably firefox, in i'm logged application send correct response if try same within browser session i'm not logged in redirected log in page. same happens if try set off request directly via httpurlconnection class. circumvent problem want send request through open browser session. code i'm using:
string callpage() { url url; string address = "novalidresponse"; try { url = new url(getmapwidgeturl()); //function delivers request url httpurlconnection connect = (httpurlconnection) url.openconnection(); //connect.setinstancefollowredirects(false); connect.setrequestmethod("get"); bufferedreader in = new bufferedreader(new inputstreamreader(connect.getinputstream())); string source = ""; string line; while((line = in.readline()) != null){ source += line; system.out.println(line); } system.out.println(source); string[] sourcesplitted = source.split(","); (int zaehler = 0; zaehler < sourcesplitted.length; zaehler++) { if (sourcesplitted[zaehler].contains("searchaddress")) { sourcesplitted[zaehler] = address; break; } } } catch (ioexception e) { system.out.println("invalid url"); return address; // returns"novalidresponse" } return address; }
Comments
Post a Comment