including apache http components in my program

J

jason

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());


}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top