Below are some answers to your questions.
1) If doing to of the same type of requests what is the correct method for
they type of action do I:
a) use two Method variables
b) use the same one with a recycle but cast it new again
c) use the same one without a recycle but cast it new
d) use the same one with a recycle but use setPath between executes
e) none of the above
There are many options. It depends what specifically your needs are. I generally only use a method once. The only real restrictions are as follows:
1 - methods are not thread safe so they can only be used by one thread at a time
2 - a method must be recycled before it can be reused
2) If doing a Post which returns another page do I need to really Get that
page?
I'm not exactly sure what your asking, but, after you do a post, the server's response can be read using one of the getResponseBody*() methods.
3) What the proper place for a method.releaseConnection? After the method,
after you are all done?
The connection should be released after it is no longer being used. A connection is given to a method each time it is executed. So, the connection is no longer being used after a particular method execution and the corresponding response are completed. It will most likely look something like:
try {
client.executeMethod(method);
// process method response here
} catch (Exception e ) {
// do something
} finally {
method.releaseConnection();
}4) Once the client is set up and configured, do you need to do anything to
maintain it?
I can't think of anything. I'm not sure what you mean by maintain though.
5) Rejected cookies. OK so the system I'm connecting to can not make a good
cookie, can't I accept it anyway?
It is possible to change the cookie parsing policy to be more lenient. Try:
CookiePolicy.setDefaultPolicy(CookiePolicy.COMPATABILITY);
6) Starting out, here the order I think is correct am I right?
a) create a host configuration
a) create a connection using that host config
b) use that connection to create a connection Manager
c) use that connection Manager to create a client
d) create a Method
e) execute that method using the host config and client
It should look something like:
HttpClient httpClient = new HttpClient();
httpClient.getHostConfiguration().setHost("jakarta.apache.org", -1, "http");
GetMethod method = new GetMethod("/");
httpClient.executeMethod(method);
Please take a look at the examples directory for some more ideas of how HttpClient can be used. The examples dir is included in the source and is also available at:
http://cvs.apache.org/viewcvs/jakarta-commons/httpclient/src/examples/
Mike
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
