Hi,
I don't know if you are sure that you want to use java for this.
If yes, I can make for you a java program that checks if server response has a cookie or not. But if not, java cannot execute of course a js script...but you can describe me what script is doing, wo we can implement similar thing in java. Or you can simply give me the url of the site you are manipulating so I can see myself what the script js is doing.
If you already have java code that you want that integrate my code within it, you wan send it to me...but this is just an option for you..
Regards,
Ayoub.