With a firefox browser I have access to a website. Using cookies I don't have to login each time.
Please explain when this is not a smart question - so I know how to go on:
Question: after logged on with the browser, can I start a Java application and re-use that cookie from the browser to directly access data on the website? So, like the browser, skipping the logon procedure?
Why - logging on with the browser goes easy in my case. Logging on from a Java application is difficult.
I hope you can help OR explain.
You can install a firebug addon to firefox, then run it by F12, go to network tab, activate it, log in to your page, you will see how the request looks like. In simple scenario everything you need is a cookie by wihich the server will authenticate you. It is very probable that you will also need to set user.agent property (without it some services doesn't allow access), eg.
java.net.URLConnection c = url.openConnection();
c.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2");
System.setProperty("http.agent", "");
to determine the exact user agent, start a http server port, connect to it from the browser and print the incoming stream.
You can also see how the cookies are stored. Try to mimic the behavior of the browser in your java code.
Some sites use other authentication mechanisms, but it is relatively rare.