From the output I understood that the website homepage does refresh and redirects the request to other page that happens ok on a browser but it doesn’t on code. so how do I move forward along with that redirection ?
try {
URL url = StringUtils.stringToURL(link);
URLConnection dbGatewayURL = url.openConnection();
dbGatewayURL.setConnectTimeout(timeout);
BufferedReader in = new BufferedReader(new InputStreamReader(
dbGatewayURL.getInputStream()));
StringBuffer responseData = new StringBuffer();
String line = "";
while ((line = in.readLine()) != null) {
responseData.append(line + "\n");
}
The Out put is:
<HEAD>
<META HTTP-EQUIV=REFRESH CONTENT="0;URL=/sites/engbm">
</HEAD>
Which raises unexpected end of file exception when I try to httpUrlConn.setRequestMethod("HEAD");
You’ll have to parse the output and look for the
<META HTTP-EQUIV=REFRESH>tag. It tells the browser that response header equivalents are being included in the content itself. In this case, it’s telling the browser to redirect to/sites/engbmafter0seconds. Just to clear up what theMETA HTTP-EQUIVis for: http://www.w3schools.com/tags/att_meta_http_equiv.aspAs for:
This is because
HEADrequests have no response body.