So I'm trying to make a very basic web browser that accomplishes very specific tasks. However, I need to get the URL from relative URLs (such as in tags. I can get both URLs, but I'm not sure how to approach relative URLs.
I am using Java 6 for compatibility with older systems (a lot older)
Basically, I have the URL "http://example.com/directory/page.html", then I have an tag with the href= "newpage.html". I want to be able to get the URL "http://example.com/directory/newpage.html".
Moreover, if its href= "../newpage.html", I want to get "http://example.com/newpage.html",
and if its href="http://example.org/dir/anotherpage.html", I want to get the URL "http://example.org/dir/anotherpage.html".
Is there any good, clean way of doing this?
URIand use its methods, then convert it back. You don't have to worry about the double dots. The Web server will understand them.