Hi everyone,
I'm trying to access a url from java (using java post method). The url is a login page. I then insert values (username and password) to it an try to post that page. Below is my code,
I get a error saying I need to enable cookie in my browser. But even after doing so it is still throwing me the same error. Below is the error message,
The print statement, i'm getting null
Any thoughts on this please do share. Thanks a lot :)
fREDDIE
I'm trying to access a url from java (using java post method). The url is a login page. I then insert values (username and password) to it an try to post that page. Below is my code,
Code:
PrintWriter out = new PrintWriter(new FileWriter("GSA Report Log.txt")); String ipAddress = "******"; //give the ipadress here int portNo = 8000; //give the port number here String path = ""; //give the path(url) String data = ""; //give the inpurt parameters URL url = null; URLConnection conn = null; OutputStreamWriter wr = null; BufferedReader rd = null; StringBuffer sbTopKeywords = new StringBuffer(); ArrayList list_TopKeywords = new ArrayList(); //Process 1 - Login to the Appliance //The Requested URL : https://ipAddress:portNo/EnterpriseController?actionType=reload&lastcmd=login System.out.println("******************** Start of Porcess 1 ********************"); path = "/EnterpriseController"; data = "userName=" + URLEncoder.encode("******", "UTF-8") + "&password=" + URLEncoder.encode("****", "UTF-8"); url = new URL("http://" + ipAddress +":"+ portNo + path); conn = url.openConnection(); conn.setDoOutput(true); wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(data); System.out.println(data); System.out.println(wr.toString()); wr.flush(); rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; while ((line = rd.readLine()) != null) { System.out.println(line); } System.out.println("******************** End of Porcess 1 ********************"); wr.close(); rd.close();
Code:
Access to this system requires that you allow cookies to be set on your computer. Please enable cookies in your browser and hit reload twice. You can find your cookie settings under "Tool s -> Internet Options" for Internet Explorer and "Edit -> Preferences& quot; for Netscape.
Code:
while ((line = rd.readLine()) != null) { System.out.println(line); }
Any thoughts on this please do share. Thanks a lot :)
fREDDIE
Comment