By the time you pasting the link, your IE probably obtained the cookie already, or it is showing you a cached page. This is what we should all blame IE. :)
Anyway, reading your code, I suggest you don't muck with the cookie yourself, since cookie can change from time to time on the server side. Hardcoding your cookie is probably worse, even you get it work now, it may blow up sooner or later. What I recommend you to do is to clear your IE as much as possible, (including cache, cookie, and close it and then reopen it), capture exactly and all the urls going to the server. Then copy those into your HttpClient code. HttpClient will handle the dynamic cookie automatically for you. (I see you setting the cookie policy, great, that is what it for). Since you can obtain your previous cookie, I assume you already know how to capture all network traffic coming out of your IE. If not, download a tool like Ethereal to help you do the monitoring and capturing. --Michael -----Original Message----- From: tom yin [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 21, 2004 3:44 PM To: Commons HttpClient Project Subject: RE: url is Re: How to accept cookies in HttpClient. Hi, Michael, Thanks a lot for your info. It's weired...In my computer, after I clean cookies, I will go to the error page if I click the link in this mail directly, but go to the right login page if I copy the link to the address bar and press enter key. The initial link is link1, http://resources.hewitt.com/jpmc/ , which will be automatically redirected to link 2, http://lb32.resources.hewitt.com/sg1dgp9/tbiappt300?nodeId=GreetingPage&clientId=09813 , Then when you click logon button, you can go to the link3 (the link I mentioned in my last email, this is the login page.) I can go to link2 by using HttpClient, but I will go to the error page when I try to access link3 using HttpClient (I have checked the cookies created in link2, and add them when I try to access link3) The source is : SpiderUtil.installSluttySocketFactory(); client = new HttpClient(); client.getState().setCookiePolicy(CookiePolicy.COMPATIBILITY ); ......................... .............................<get link2> client.getHostConfiguration().setHost("lb32.resources.hewitt.com", 443, "https"); <get namevaluePairs from XML files here> HostConfiguration conf = new HostConfiguration(); conf.setHost("lb32.resources.hewitt.com", 443, "https"); GetMethod defaultpage = new GetMethod("/sg1dgp9/tbiappt300/TbiaAuthPage"); defaultpage.setFollowRedirects(false); defaultpage.setQueryString(nameValuePairs); Cookie mycook= new Cookie("lb32.resources.hewitt.com", "JSESSIONID_SG1_DGP9", "000104LCHDF43OXZWZ03OD402DQ:uvjppnh8", "/", null, false); Cookie mycook2 = new Cookie("lb32.resources.hewitt.com", "YBR_PROFILE", "09813:1095803338557:15:false:YBRSessTS1095803338505", "/sg1dgp9", null, false); HttpState httpstate=new HttpState(); httpstate.addCookie(mycook); httpstate.addCookie(mycook2); client.executeMethod(conf, defaultpage, httpstate); Michael Dang <[EMAIL PROTECTED]> wrote: Open your alternate browser (Netscape? Mozilla?), or go to another machine and open IE, goto the url you sent, you will see the error page. Exactly it is the cookie you missed. So, clear your IE's cookie cache, find your way back to the site using the clean IE (well, IE never clean as it should), then follow the same path in HttpClient. --Michael -----Original Message----- From: tom yin [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 21, 2004 2:37 PM To: [EMAIL PROTECTED] Subject: url is Re: How to accept cookies in HttpClient. Hello, I've forgotten to tell you guys the url, which is: https://lb32.resources.hewitt.com/sg1dgp9/tbiappt300/TbiaAuthPage?Submit=Log+On&clientId=09813&emClientId=&create=1095797686983&remoteServer=false&bp=false&sslActive=true&QATest=null&nodeId=EnterTheSitePage&u=1095797686983&wdw=YBRPrimary&JavaScriptEnabled=TRUE&lDt=1095797520203&ulDt=1095801760921&fn=GreetingPage&fWdw=YBRPrimary&isSSO=false&isYTR=false&%5EuniqueValue=1095797686985&%5EendOfForm=EOF I can reach the login page by accessing this url in IE, but can not by httpClient. If any comments, I will appreciate it. Thanks. Tom tom yin wrote: Hi, All, I got a problem when I try to go to a login page of a website. My code is like this: GetMethod defaultpage = new GetMethod(link); //defaultpage.setFollowRedirects(true); defaultpage.setQueryString(nameValuePairs); //defaultpage.setRequestBody(nameValuePairs); client.executeMethod(defaultpage); It's very simple, but I can not go to the login page expected, but redirected to an error page, which has the following information: You've received this message for one of the following reasons: The Enter the Site page is bookmarked or added to your favorites. If so, please delete that bookmark. You can bookmark the Welcome page instead. Your browser doesn't support cookies, or you've set your browser to not accept cookies. Please use one of the recommended browsers or set your browser preferences to accept cookies. Contact your browser developer (for example, Microsoft or Netscape) if you need help setting your browser preferences. Is this a cookies problem? If I reach the website by IE, no problem happens. Please help. Thanks. --------------------------------- Do you Yahoo!? vote.yahoo.com - Register online to vote today! --------------------------------- Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------- Do you Yahoo!? vote.yahoo.com - Register online to vote today! --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]