Oleg, The login seems to be successful. The reason is that authpost.getResponseBodyAsString() returns the javascript that re-directs the web site. It is the same javascript if I login to the site manually. I do not know why the session cookies are not generated corrrectly.
I use the traffic analyzer to capture the http traffic. The initial tries only give me the ip addresses, not to the details for http handshake. I need to spend more. Thank you very much ! David --- Oleg Kalnichevski <[EMAIL PROTECTED]> wrote: > David, > > My only guess is that the logon request (POST > /iddb3/iddb3_2/login.verify) fails due to invalid > credentials or some > other reason. I see no session cookie in the > response. The UserId and > pUserId cookies are too simple and may not > necessarily be session > cookies. > > Anyways, knowing what exactly what handshake the > site expects is your > best chance. Take a look at the Ethereal > > http://www.ethereal.com/download.html > > See if you succeed in capturing the HTTP traffic > between the browser and > the site using this tool. > > Cheers, > > Oleg > > > On Sat, 2004-09-11 at 16:13, David Qain wrote: > > Oleg, > > > > Thank you very much for your quick response. > > > > During manual login to the site, I captured the > > redirect URL from the java script and saved it in > the > > html file. If one browser logins already, > clicking > > the saved html file will open a browser and > automatic > > logins. > > > > The returned status code from the first PostMethod > is > > 200, but redirect code. I searched the mail list > and > > found some one got 200 for redirecting the > website. > > > > The log file is attached. What traffic analyzer > would > > you recommend ? I can not install the traffic > > analyzer on the server side since it is a > commercial > > web site. Can I still install it on the client > side ? > > > > Thank you very much for your advices. > > > > David > > > > > > > > > > --- Oleg Kalnichevski <[EMAIL PROTECTED]> wrote: > > > > > 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 > > > > "); > === message truncated === __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]