Ok, lucky for me this was very simple. I just replaced Document doc = Jsoup.connect(url).get();
with Document doc = Jsoup.parse(html);
So in the code of the main post I replaced //TODO
with:
Document doc = Jsoup.parse(response);
org.jsoup.nodes.Element el = doc.select("input[name*=" + TOKEN).first();
hidden_token = el.attr("value");
Edit 1:
I thought this did the trick, but it doesn't.. It still thinks there are two different Sessions
opened.. :S
Does Jsoup.parse(...)
open a new Jsoup.get-session
behind the scenes?
Edit 2:
It's even worse.. Every time another page is opened on the website, another session is created and therefore another token is needed.. So I need to discuss some things with the creator of the website/web api hybrid and figure some things out.. Perhaps create a different log-in just for the Web API..
All in all I'm kinda frustrated right now, even though all the problems I've encountered are "solved"..