How to find whether a page is redirecting or not?
I wanna know that how we can identify whet开发者_C百科her a page is redirecting to some other web page or not?
I'm using URLConnection class of java. One way that i know is, to check the headerfield 'Location' of the connection established.
But i'm not getting the solution :-(
Plz assist.
Start using HttpClient and stop worrying about redirects.
Read here for more details.
Java HttpURLConnection follow redirects automatically, unless you call
HttpURLConnection.setFollowRedirects(false);
try calling it before you open the url (you only need to do it once, it's a static function).
I am not sure if the Location header is respected by Java (it can be a browser only thing), but you should see an http response code of 301 or 302 (if I am not mistaken) which indicates a redirect in http level.
精彩评论