Redirecting to new page after loging using HttpsURLConnection

I have following task:
1. login to yahoo
2. after successful login go to
3. parse some information e.g. stock quote
4. I want to repeat operation each 5 minutes to get the same , refreshed page, so do I have to re-establish connection or reuse existing one with refresh mechanizm ?

I was able to finish 1. connect but result looks like this:
<script language="JavaScript">
// -->
<meta http-equiv="Refresh" content="0; url=">
If you are seeing this page, your browser settings prevent you
from automatically redirecting to a new URL.
Please <a href="">click here</a> to continue.

so it looks, after login i am not redirecting but in my code
I am using HttpsURLConnection.setFollowRedirects(true);
so It shoud work. My guess is , that javscript is not executed.

thanks in advance for any help

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

not sure but use
setFollowRedirects() should be invoked before url.openConnection() otherwise it wont work then you have to call setInstanceFollowRedirects()
man, dont you think that HttpUrlConnection doesn't parse the html content and it cant understand javascript ? you need to do it manualy
as a last comment
I found that setFolowRedirects just follows the http redirect instructions
i.e in php you use header('Location: '. $to);  to send a raw http header
setFolowRedirects is by default true
I have tested it on my local apache server and it worked fine (no need to serFolowRedirects(true))
the page you are viewing is attempting to redirect with two different mechanisms a javascript and an html (<meta http-equiv="Refresh") and non of them is understandable by HttpUrlConnection alone,
and the only way is to parse the html result and find window.location is assigned to what and the go there manualy

assume this code
HttpURLConnection con = (HttpURLConnection) HOST.openConnection();
con.setInstanceFollowRedirects(false); // as i told dont use static method setFollowRedirects() after openconnection

then if you look through header fileds --> con.getHeaderFieldKey(index) and con.getHeaderField(index);
you can see a filed with name:location and value:redirect location
it is through this header that HttpURLConnection realizes redirection and no other way

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.