You should study HTTP and HTML to see what a browser sends to a server and what the server returns to the browser.
It's possible in some cases to write a java program that works like a browser.