I have been looking for some time, and I do not find a clear answer. I am trying to login to webstie. https://hrlink.healthnet.com/ This website redirects to a login page, which is optional. I have to publish my credentials for the redirected URL.
I am trying to encode this in Java, but I do not understand how to get the URL from the response. It may look a little dirty, but I have it while I'm testing.
HttpGet httpget = new HttpGet("https://hrlink.healthnet.com/"); HttpResponse response = httpclient.execute(httpget);HttpEntity entity = response.getEntity(); String redirectURL = ""; for(org.apache.http.Header header : response.getHeaders("Location")) { redirectURL += "Location: " + header.getValue()) + "\r\n"; } InputStream is; is = entity.getContent(); 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(); String result = sb.toString();
I know that they redirect me because my result line shows the actual login page, but I canβt get the new URL.
In FireFox, I am using TamperData. When I go to this website https://hrlink.healthnet.com/ , I have a GET with 302 - Found and Location of the Login. Then another GET to the actual login page
Any help gratefully thanks you.
source share