I'm attempting to set my user agent string within the HttpClient apache object in Java however i cannot discover how to get it done.

Help!

Also I'm attempting to enable redirects to true but additionally cannot find this method inside the HttpClient object.

Thanks

Andy

HttpClient httpclient = new HttpClient();
httpclient.getParams().setParameter(
    HttpMethodParams.USER_AGENT,
    "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2"
);

With HttpClient 4., the next labored for me personally:

import org.apache.http.params.HttpProtocolParams;

HttpClient httpclient = new HttpClient();
HttpProtocolParams.setUserAgent(httpclient.getParams(), "My fancy UA");

HttpProtocolParams resides within the httpcore JAR file: http://hc.apache.org/httpcomponents-core/download.html