F
farazkazmi
I m facing dificulty with http "POST" request.
i need to login to a website " https://www.orkut.com "
it requires username and password.
i dont know how to enter username and password so that i can access the
page by myjava class.
i m using this code gor gettinh request:
public static String GetRequest() throws IOException {
String urlString = "https://www.orkut.com";
DataInputStream dis = null;
StringBuffer message = new StringBuffer();
String outputMessage = new String();
URL url = new URL(urlString);
HttpURLConnection httpConnection =
(HttpURLConnection) url.openConnection();
httpConnection.setRequestMethod("GET");
httpConnection.setDoInput(true);
Properties props = System.getProperties();
props.put("http.proxyHost", "SERVER");
props.put("http.proxyPort", "8080");
httpConnection.connect();
System.out.println(httpConnection.getResponseCode());
dis = new DataInputStream(httpConnection.getInputStream());
int ch;
while ((ch = dis.read()) != -1) {
message.append((char) ch);
}
outputMessage = message.toString();
//System.out.println(outputMessage);
httpConnection.disconnect();
return outputMessage;
}
now if i change request method to POST , then plz tell me how can i
enter username and password by my java code.
fhkazmi
i need to login to a website " https://www.orkut.com "
it requires username and password.
i dont know how to enter username and password so that i can access the
page by myjava class.
i m using this code gor gettinh request:
public static String GetRequest() throws IOException {
String urlString = "https://www.orkut.com";
DataInputStream dis = null;
StringBuffer message = new StringBuffer();
String outputMessage = new String();
URL url = new URL(urlString);
HttpURLConnection httpConnection =
(HttpURLConnection) url.openConnection();
httpConnection.setRequestMethod("GET");
httpConnection.setDoInput(true);
Properties props = System.getProperties();
props.put("http.proxyHost", "SERVER");
props.put("http.proxyPort", "8080");
httpConnection.connect();
System.out.println(httpConnection.getResponseCode());
dis = new DataInputStream(httpConnection.getInputStream());
int ch;
while ((ch = dis.read()) != -1) {
message.append((char) ch);
}
outputMessage = message.toString();
//System.out.println(outputMessage);
httpConnection.disconnect();
return outputMessage;
}
now if i change request method to POST , then plz tell me how can i
enter username and password by my java code.
fhkazmi