David,

Just a few comments

(1) This is unrelated to your problem, but do make sure you release
connection when you are done with the method. In most cases HttpClient
will do its very best to automatically release the connection, but in
some cases (like the response content consumed partially) HttpClient
simply cannot know that the method and the connection associated with it
are not longer needed.

The general pattern should always be

HttpMethod httpmethod = new GetMethod("/whatever");
try {
  httpclient.executeMethod(httpmethod);
  // do stuff. 
} finally {
  httpmethod.releaseConnection();
}

This can save you A LOT of grief should you decide to use HttpClient
with a multi-threaded connection manager or if some of your methods do
not consume the response content in its entirety

For details see the tutorial:

http://jakarta.apache.org/commons/httpclient/tutorial.html

(2) As to the main issue, apparently the redirect URL is invalid. I
could possibly say more if I had the log, but the log you attached to
your previous message did not get through. Try attaching the log inline
or send it to me directly

Another idea would be to capture the exact transaction between and the
browser and the site using a traffic analyzer and then implement the
same logic with HttpClient

Hope this helps


Oleg


On Sat, 2004-09-11 at 03:59, David Qain wrote:
> Hello,
> 
> I am new to HttpClient.  I tried to follow
> FormLoginDemo to log in the a web site.  After
> entering the user name and password, the site is
> redirected to a new url using the javascript.  The
> program uses the PostMethod to login to the web site
> successfully since the cookies are created.  But it
> can not use GetMethod to redirect to the page using
> the URL from returned javascript.  The "HTTP/1.1 404
> Not Found" was found in the log file.  But I was able
> to login the web site using the re-direct URL from
> javascripts using the web browser.  Here are part of
> codes:
> 
>  static final String LOGON_SITE = "www.iddb.com";
>  static final int    LOGON_PORT = 80;
> 
>         HttpClient client = new HttpClient();
>        
> client.getHostConfiguration().setHost(LOGON_SITE,
> LOGON_PORT, "http");
>        
> client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
>         
>         PostMethod authpost = new
> PostMethod("/iddb3/iddb3_2/login.verify");
>         // Prepare login parameters
>         NameValuePair userid   = new
> NameValuePair("username_in", "user");
>         NameValuePair password = new
> NameValuePair("password_in", "password");
>         NameValuePair autologin = new
> NameValuePair("autologin", "Y");
>         NameValuePair i_login = new
> NameValuePair("i_login", "Y");
>            
>         authpost.setRequestBody( 
>           new NameValuePair[] { userid, password,
> autologin, i_login});
>  
>         int statuscode2 =
> client.executeMethod(authpost);
> 
>         GetMethod redirect1 = new
> GetMethod("/iddb3/iddb3_2/alerts.get_alert?v_alert_type=Drug&v_clear_trail=Y
> ");
>         
>         c1.executeMethod(redirect1 );
> 
> The log file is attached.
> 
> Thank you very much for your help !
> 
> David
> 
> 
> 
>       
>               
> __________________________________
> Do you Yahoo!?
> New and Improved Yahoo! Mail - 100MB free storage!
> http://promotions.yahoo.com/new_mail
> 
> ______________________________________________________________________
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to