I have to login into a https web page and download a file using Java. I know all the URLs beforehand:
baseURL = // a https URL;
urlMap = new HashMap
I agree with Alnitak that the problem is likely storing and returning cookies.
Another good option I have used is HttpClient from Jakarta Commons.
It's worth noting, as an aside, that if this is a server you control, you should be aware that sending the username and password as querystrings is not secure (even if you're using HTTPS). HttpClient supports sending parameters using POST, which you should consider.