I'm trying to read a web site as an HTMLDocument; and the site requires either a cookie from a previous logon, or a response to a popup dialog. I'm thinking that supplying the necessary cookie is the easiest to accomplish, but I haven't found a way to do that. The code to open and read the document is:
URL url = new URL(suppliedURL);
URLConnection conn = url.openConnection();
InputStream is = conn.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
HTMLEditorKit htmlKit = new HTMLEditorKit();
HTMLDocument htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument();
HTMLEditorKit.Parser parser = new ParserDelegator();
HTMLEditorKit.ParserCallback callback = htmlDoc.getReader(0);
parser.parse(br, callback, true);
The retrieved document contains incorrect information that can only be corrected by invoking a logon dialog or supplying a cookie.
So the questions are:
How do I supply a cookie when opening this page?
How do I copy the information from an existing IE cookie to the cookie I supply?