Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2011
    Posts
    1
    Rep Power
    0

    Post Unable to call setRedirectStrategy() method through object DefaultHttpClient Class

    Hi,
    I have imported following JAR files:-
    1. HttpClient4.1.2
    2. Httpcore4.1.2
    3. HttpClient-Cache4.1.2

    Also explicitly importing following file:-
    1. import org.apache.http.impl.client.DefaultHttpClient;

    Still I am unable to Call setRedirectStrategy() method using an Object of Class DefaultHttpClient.

    Root Cause:-
    setRedirectStrategy() method is defined under AbstractHttpClient Class which is extented by DefaultHttpClient class. But still unable to call the required method.

    Snap Shot of the code:-
    public static void main(String[] args) throws ClientProtocolException,
    IOException, NoSuchAlgorithmException, KeyManagementException {

    DefaultHttpClient httpclient = new DefaultHttpClient();
    httpclient.getParams().setBooleanParameter(
    "http.protocol.allow-circular-redirects", true);
    httpclient.getParams().setParameter(ClientPNames.C OOKIE_POLICY,
    CookiePolicy.BROWSER_COMPATIBILITY);
    httpclient.getParams()
    .setParameter(ClientPNames.HANDLE_REDIRECTS, true);

    httpclient.setRedirectStrategy(new Redirector()); //HERE IS THE PROBLEM

    Error displayed:-
    The method setRedirectStrategy(Redirector) is undefined for the type DefaultHttpClient

    Regards,
    Ashish

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: Unable to call setRedirectStrategy() method through object DefaultHttpClient Clas

    The signature for setRedirectStrategy is:
    public void setRedirectStrategy(RedirectStrategy redirectStrategy)

    Unless a Redirector implements RedirectStrategy (which the error implies it doesn't) then your call is indeed wrong.

Similar Threads

  1. Unable to access getter method in an object class I made
    By EnSlavingBlair in forum New To Java
    Replies: 6
    Last Post: 10-01-2011, 10:52 AM
  2. Replies: 0
    Last Post: 03-27-2011, 05:49 AM
  3. Call object methods from another class
    By africanhacker in forum New To Java
    Replies: 16
    Last Post: 03-22-2011, 01:10 AM
  4. How to call an object from another class?
    By narty in forum New To Java
    Replies: 1
    Last Post: 11-01-2010, 08:14 PM
  5. Unable to call paint() from inside method
    By Y. Progammer in forum New To Java
    Replies: 3
    Last Post: 03-01-2010, 12:47 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •