Prev: tomcat classloader
Next: hibernate find method ?
From: jason on 3 Jun 2010 23:11 i am trying to run basic program for apache http components and i cannot for the life of me figure out how to include this library within my program. if someone is willing to help me while i struggle through this and just help me solve this question it would be largely appreciated. i honestly have no idea what i am doing/doing wrong and feel as if i am beating my head against the wall i am downloading binary with deps including the folder as a source folder in my package properties. and no luck. code i am trying to run: package hackthissiteapp1; import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.methods.*; public class Main { public static void main(String[] args) throws Exception { HttpClient client = new HttpClient(); GetMethod getPage = new GetMethod("http:// www.hackthissite.org"); client.executeMethod(getPage); PostMethod postLogin = new PostMethod("http:// www.hackthissite.org/pages/index/index2.php"); NameValuePair[] data = { new NameValuePair("txt_username", "MYUSERNAME"), new NameValuePair("txt_password", "MYPASSWORD"), new NameValuePair("btn_submit","Login") }; postLogin.setRequestBody(data); client.executeMethod(postLogin); //this is a request to a page that requires authentication GetMethod getPage2 = new GetMethod("http:// www.hackthissite.org/missions/basic/"); client.executeMethod(getPage2); System.out.println(getPage2.getResponseBodyAsString()); } }
From: jason on 3 Jun 2010 23:20 i got it to work. nevermind, sorry for the desperation!
|
Pages: 1 Prev: tomcat classloader Next: hibernate find method ? |