I'm working on a desktop application using Swing. I have figured out how to log into a website using a POST request and receiving the HTML response. Now I need to send the received HTML to the default browser. Basically, displaying to the user what the browser is returning to me in the background. I have read a bit about set header, etc.
So my question is, how can I post html code from java into a browser in such a manner that it displays as a website and not just text?
I would love not to have to use any server (Socket) type code because I feel there is a compatibility risk if the program is run from different computers.
// Log Into Website
URL objtest = new URL("http://rccpdems01/ems/Login.php/Login.php");
HttpURLConnection con = (HttpURLConnection) objtest.openConnection();
con.setRequestMethod("POST");
String datas = "userid=Gt737326&psword=Test&btnLogin=Login";
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(datas);
wr.flush();
wr.close();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();