Dear, I finally figure out how to log!!
The SimpleLog can't work, but the log4j works. Below is the log. executing: POST https://127.0.0.1/agent/xml/login.xml HTTP/1.1 ---- DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.max-redirects': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection-manager.timeout': null DEBUG [org.apache.http.impl.conn.SingleClientConnManager] SingleClientConnManager.getConnection: HttpRoute[{s}->https://127.0.0.1] DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.timeout': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.timeout': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.tcp.nodelay': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.timeout': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.linger': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.buffer-size': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.element-charset': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.max-line-length': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.element-charset': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.max-header-count': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.max-line-length': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.max-status-line-garbage': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.stalecheck': null DEBUG [org.apache.http.impl.client.DefaultClientRequestDirector] Stale connection check DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.virtual-host': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.default-headers': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version': HTTP/1.1 DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.useragent': Apache-HttpClient/4.0-alpha3 (java 1.4) DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version': HTTP/1.1 DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.expect-continue': true DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.cookie-policy': null DEBUG [org.apache.http.client.protocol.RequestAddCookies] CookieSpec selected: best-match DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.cookie-datepatterns': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.single-cookie-header': null DEBUG [org.apache.http.impl.client.DefaultClientRequestDirector] Attempt 1 to execute request DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version': HTTP/1.1 DEBUG [org.apache.http.wire] >> "POST /agent/xml/login.xml HTTP/1.1[EOL]" DEBUG [org.apache.http.wire] >> "Content-Length: 225[EOL]" DEBUG [org.apache.http.wire] >> "Content-Type: application/x-www-form-urlencoded[EOL]" DEBUG [org.apache.http.wire] >> "Host: 127.0.0.1[EOL]" DEBUG [org.apache.http.wire] >> "Connection: Keep-Alive[EOL]" DEBUG [org.apache.http.wire] >> "User-Agent: Apache-HttpClient/4.0-alpha3 (java 1.4)[EOL]" DEBUG [org.apache.http.wire] >> "Expect: 100-Continue[EOL]" DEBUG [org.apache.http.wire] >> "[EOL]" DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version': HTTP/1.1 DEBUG [org.apache.http.headers] >> POST /agent/xml/login.xml HTTP/1.1 DEBUG [org.apache.http.headers] >> Content-Length: 225 DEBUG [org.apache.http.headers] >> Content-Type: application/x-www-form-urlencoded DEBUG [org.apache.http.headers] >> Host: 127.0.0.1 DEBUG [org.apache.http.headers] >> Connection: Keep-Alive DEBUG [org.apache.http.headers] >> User-Agent: Apache-HttpClient/4.0-alpha3 (java 1.4) DEBUG [org.apache.http.headers] >> Expect: 100-Continue DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version': HTTP/1.1 DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.wait-for-continue': null DEBUG [org.apache.http.wire] << "HTTP/1.1 100 Continue[EOL]" DEBUG [org.apache.http.headers] << HTTP/1.1 100 Continue DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version': HTTP/1.1 DEBUG [org.apache.http.wire] >> "jaxbString=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22+standalone%3D%22yes%22%3F%3E%0A%3Clogin%3E%0A++++%3CphaseKey%3Epowerpanel.encryption.key%3C%2FphaseKey%3E%0A++++%3Cresult%3E-1%3C%2Fresult%3E%0A%3C%2Flogin%3E%0A" DEBUG [org.apache.http.wire] << "HTTP/1.1 302 Moved Temporarily[EOL]" DEBUG [org.apache.http.wire] << "Server: Apache-Coyote/1.1[EOL]" DEBUG [org.apache.http.wire] << "Set-Cookie: JSESSIONID=A8DEFC59DB38202BBEF794ABF9556991; Path=/agent; Secure[EOL]" DEBUG [org.apache.http.wire] << "Pragma: No-cache[EOL]" DEBUG [org.apache.http.wire] << "Cache-Control: no-cache,no-store,max-age=0[EOL]" DEBUG [org.apache.http.wire] << "Expires: Thu, 01 Jan 1970 00:00:00 GMT[EOL]" DEBUG [org.apache.http.wire] << "Location: https://127.0.0.1:8443/agent/xml/login.xml;jsessionid=A8DEFC59DB38202BBEF794ABF9556991?jaxbString=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22+standalone%3D%22yes%22%3F%3E%0A%3Clogin%3E%0A++++%3CphaseKey%3Epowerpanel.encryption.key%3C%2FphaseKey%3E%0A++++%3Cresult%3E-1%3C%2Fresult%3E%0A%3C%2Flogin%3E%0A[EOL]" DEBUG [org.apache.http.wire] << "Content-Type: text/html[EOL]" DEBUG [org.apache.http.wire] << "Content-Length: 0[EOL]" DEBUG [org.apache.http.wire] << "Date: Fri, 07 Mar 2008 05:10:44 GMT[EOL]" DEBUG [org.apache.http.headers] << HTTP/1.1 302 Moved Temporarily DEBUG [org.apache.http.headers] << Server: Apache-Coyote/1.1 DEBUG [org.apache.http.headers] << Set-Cookie: JSESSIONID=A8DEFC59DB38202BBEF794ABF9556991; Path=/agent; Secure DEBUG [org.apache.http.headers] << Pragma: No-cache DEBUG [org.apache.http.headers] << Cache-Control: no-cache,no-store,max-age=0 DEBUG [org.apache.http.headers] << Expires: Thu, 01 Jan 1970 00:00:00 GMT DEBUG [org.apache.http.headers] << Location: https://127.0.0.1:8443/agent/xml/login.xml;jsessionid=A8DEFC59DB38202BBEF794ABF9556991?jaxbString=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22+standalone%3D%22yes%22%3F%3E%0A%3Clogin%3E%0A++++%3CphaseKey%3Epowerpanel.encryption.key%3C%2FphaseKey%3E%0A++++%3Cresult%3E-1%3C%2Fresult%3E%0A%3C%2Flogin%3E%0A DEBUG [org.apache.http.headers] << Content-Type: text/html DEBUG [org.apache.http.headers] << Content-Length: 0 DEBUG [org.apache.http.headers] << Date: Fri, 07 Mar 2008 05:10:44 GMT DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version': HTTP/1.1 DEBUG [org.apache.http.client.protocol.ResponseProcessCookies] Cookie accepted: "[version: 0][name: JSESSIONID][name: A8DEFC59DB38202BBEF794ABF9556991][domain: 127.0.0.1][path: /agent][expiry: null]". DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.handle-redirects': null DEBUG [org.apache.http.impl.client.DefaultRedirectHandler] Redirect requested to location 'https://127.0.0.1:8443/agent/xml/login.xml;jsessionid=A8DEFC59DB38202BBEF794ABF9556991?jaxbString=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22+standalone%3D%22yes%22%3F%3E%0A%3Clogin%3E%0A++++%3CphaseKey%3Epowerpanel.encryption.key%3C%2FphaseKey%3E%0A++++%3Cresult%3E-1%3C%2Fresult%3E%0A%3C%2Flogin%3E%0A' DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.allow-circular-redirects': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.route.forced-route': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.route.local-address': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.route.default-proxy': null DEBUG [org.apache.http.impl.client.DefaultClientRequestDirector] Redirecting to 'https://127.0.0.1:8443/agent/xml/login.xml;jsessionid=A8DEFC59DB38202BBEF794ABF9556991?jaxbString=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22+standalone%3D%22yes%22%3F%3E%0A%3Clogin%3E%0A++++%3CphaseKey%3Epowerpanel.encryption.key%3C%2FphaseKey%3E%0A++++%3Cresult%3E-1%3C%2Fresult%3E%0A%3C%2Flogin%3E%0A' via HttpRoute[{s}->https://127.0.0.1:8443] DEBUG [org.apache.http.impl.client.DefaultClientRequestDirector] Connection kept alive DEBUG [org.apache.http.impl.conn.SingleClientConnManager] SingleClientConnManager.getConnection: HttpRoute[{s}->https://127.0.0.1:8443] DEBUG [org.apache.http.impl.conn.DefaultClientConnection] Connection shut down DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.timeout': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.timeout': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.tcp.nodelay': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.timeout': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.linger': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.buffer-size': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.element-charset': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.max-line-length': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.element-charset': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.max-header-count': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.max-line-length': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.max-status-line-garbage': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.stalecheck': null DEBUG [org.apache.http.impl.client.DefaultClientRequestDirector] Stale connection check DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.virtual-host': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.default-headers': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.useragent': Apache-HttpClient/4.0-alpha3 (java 1.4) DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.cookie-policy': null DEBUG [org.apache.http.client.protocol.RequestAddCookies] CookieSpec selected: best-match DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.cookie-datepatterns': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.single-cookie-header': null DEBUG [org.apache.http.client.protocol.RequestAddCookies] Cookie [version: 0][name: JSESSIONID][name: A8DEFC59DB38202BBEF794ABF9556991][domain: 127.0.0.1][path: /agent][expiry: null] match [(secure)127.0.0.1:8443/agent/xml/login.xml;jsessionid=A8DEFC59DB38202BBEF794ABF9556991] DEBUG [org.apache.http.impl.client.DefaultClientRequestDirector] Attempt 2 to execute request DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version': HTTP/1.1 DEBUG [org.apache.http.wire] >> "GET /agent/xml/login.xml;jsessionid=A8DEFC59DB38202BBEF794ABF9556991?jaxbString=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22+standalone%3D%22yes%22%3F%3E%0A%3Clogin%3E%0A++++%3CphaseKey%3Epowerpanel.encryption.key%3C%2FphaseKey%3E%0A++++%3Cresult%3E-1%3C%2Fresult%3E%0A%3C%2Flogin%3E%0A HTTP/1.1[EOL]" DEBUG [org.apache.http.wire] >> "Host: 127.0.0.1:8443[EOL]" DEBUG [org.apache.http.wire] >> "Connection: Keep-Alive[EOL]" DEBUG [org.apache.http.wire] >> "User-Agent: Apache-HttpClient/4.0-alpha3 (java 1.4)[EOL]" DEBUG [org.apache.http.wire] >> "Cookie: JSESSIONID=A8DEFC59DB38202BBEF794ABF9556991[EOL]" DEBUG [org.apache.http.wire] >> "Cookie2: $Version=1[EOL]" DEBUG [org.apache.http.wire] >> "[EOL]" DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version': HTTP/1.1 DEBUG [org.apache.http.headers] >> GET /agent/xml/login.xml;jsessionid=A8DEFC59DB38202BBEF794ABF9556991?jaxbString=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22+standalone%3D%22yes%22%3F%3E%0A%3Clogin%3E%0A++++%3CphaseKey%3Epowerpanel.encryption.key%3C%2FphaseKey%3E%0A++++%3Cresult%3E-1%3C%2Fresult%3E%0A%3C%2Flogin%3E%0A HTTP/1.1 DEBUG [org.apache.http.headers] >> Host: 127.0.0.1:8443 DEBUG [org.apache.http.headers] >> Connection: Keep-Alive DEBUG [org.apache.http.headers] >> User-Agent: Apache-HttpClient/4.0-alpha3 (java 1.4) DEBUG [org.apache.http.headers] >> Cookie: JSESSIONID=A8DEFC59DB38202BBEF794ABF9556991 DEBUG [org.apache.http.headers] >> Cookie2: $Version=1 DEBUG [org.apache.http.wire] << "HTTP/1.1 200 OK[EOL]" DEBUG [org.apache.http.wire] << "Server: Apache-Coyote/1.1[EOL]" DEBUG [org.apache.http.wire] << "Pragma: No-cache[EOL]" DEBUG [org.apache.http.wire] << "Cache-Control: no-cache,no-store,max-age=0[EOL]" DEBUG [org.apache.http.wire] << "Expires: Thu, 01 Jan 1970 00:00:00 GMT[EOL]" DEBUG [org.apache.http.wire] << "Content-Type: text/xml;charset=UTF-8[EOL]" DEBUG [org.apache.http.wire] << "Content-Length: 147[EOL]" DEBUG [org.apache.http.wire] << "Date: Fri, 07 Mar 2008 05:10:44 GMT[EOL]" DEBUG [org.apache.http.headers] << HTTP/1.1 200 OK DEBUG [org.apache.http.headers] << Server: Apache-Coyote/1.1 DEBUG [org.apache.http.headers] << Pragma: No-cache DEBUG [org.apache.http.headers] << Cache-Control: no-cache,no-store,max-age=0 DEBUG [org.apache.http.headers] << Expires: Thu, 01 Jan 1970 00:00:00 GMT DEBUG [org.apache.http.headers] << Content-Type: text/xml;charset=UTF-8 DEBUG [org.apache.http.headers] << Content-Length: 147 DEBUG [org.apache.http.headers] << Date: Fri, 07 Mar 2008 05:10:44 GMT DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version': HTTP/1.1 DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.handle-redirects': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.handle-authentication': null When I success login the xml page, I continue to next page. executing: POST http://127.0.0.1/agent/xml/update_communication.xml HTTP/1.1 ---- DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.max-redirects': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection-manager.timeout': null DEBUG [org.apache.http.impl.conn.SingleClientConnManager] SingleClientConnManager.getConnection: HttpRoute[{}->http://127.0.0.1] DEBUG [org.apache.http.impl.conn.DefaultClientConnection] Connection shut down DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.timeout': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.tcp.nodelay': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.timeout': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.linger': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.socket.buffer-size': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.element-charset': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.max-line-length': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.element-charset': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.max-header-count': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.max-line-length': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.max-status-line-garbage': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.connection.stalecheck': null DEBUG [org.apache.http.impl.client.DefaultClientRequestDirector] Stale connection check DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.virtual-host': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.default-headers': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version': HTTP/1.1 DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.useragent': Apache-HttpClient/4.0-alpha3 (java 1.4) DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.cookie-policy': null DEBUG [org.apache.http.client.protocol.RequestAddCookies] CookieSpec selected: best-match DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.cookie-datepatterns': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.single-cookie-header': null DEBUG [org.apache.http.impl.client.DefaultClientRequestDirector] Attempt 1 to execute request DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version': HTTP/1.1 DEBUG [org.apache.http.wire] >> "POST /agent/xml/update_communication.xml HTTP/1.1[EOL]" DEBUG [org.apache.http.wire] >> "Content-Length: 0[EOL]" DEBUG [org.apache.http.wire] >> "Host: 127.0.0.1[EOL]" DEBUG [org.apache.http.wire] >> "Connection: Keep-Alive[EOL]" DEBUG [org.apache.http.wire] >> "User-Agent: Apache-HttpClient/4.0-alpha3 (java 1.4)[EOL]" DEBUG [org.apache.http.wire] >> "[EOL]" DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version': HTTP/1.1 DEBUG [org.apache.http.headers] >> POST /agent/xml/update_communication.xml HTTP/1.1 DEBUG [org.apache.http.headers] >> Content-Length: 0 DEBUG [org.apache.http.headers] >> Host: 127.0.0.1 DEBUG [org.apache.http.headers] >> Connection: Keep-Alive DEBUG [org.apache.http.headers] >> User-Agent: Apache-HttpClient/4.0-alpha3 (java 1.4) DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version': HTTP/1.1 DEBUG [org.apache.http.wire] << "HTTP/1.1 200 OK[EOL]" DEBUG [org.apache.http.wire] << "Server: Apache-Coyote/1.1[EOL]" DEBUG [org.apache.http.wire] << "Set-Cookie: JSESSIONID=6095180651415AEF58669DE43A36096D; Path=/agent[EOL]" DEBUG [org.apache.http.wire] << "Pragma: No-cache[EOL]" DEBUG [org.apache.http.wire] << "Cache-Control: no-cache,no-store,max-age=0[EOL]" DEBUG [org.apache.http.wire] << "Expires: Thu, 01 Jan 1970 00:00:00 GMT[EOL]" DEBUG [org.apache.http.wire] << "Content-Type: text/html;charset=UTF-8[EOL]" DEBUG [org.apache.http.wire] << "Transfer-Encoding: chunked[EOL]" DEBUG [org.apache.http.wire] << "Date: Fri, 07 Mar 2008 05:10:44 GMT[EOL]" DEBUG [org.apache.http.headers] << HTTP/1.1 200 OK DEBUG [org.apache.http.headers] << Server: Apache-Coyote/1.1 DEBUG [org.apache.http.headers] << Set-Cookie: JSESSIONID=6095180651415AEF58669DE43A36096D; Path=/agent DEBUG [org.apache.http.headers] << Pragma: No-cache DEBUG [org.apache.http.headers] << Cache-Control: no-cache,no-store,max-age=0 DEBUG [org.apache.http.headers] << Expires: Thu, 01 Jan 1970 00:00:00 GMT DEBUG [org.apache.http.headers] << Content-Type: text/html;charset=UTF-8 DEBUG [org.apache.http.headers] << Transfer-Encoding: chunked DEBUG [org.apache.http.headers] << Date: Fri, 07 Mar 2008 05:10:44 GMT DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.version': HTTP/1.1 DEBUG [org.apache.http.client.protocol.ResponseProcessCookies] Cookie accepted: "[version: 0][name: JSESSIONID][name: 6095180651415AEF58669DE43A36096D][domain: 127.0.0.1][path: /agent][expiry: null]". DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.handle-redirects': null DEBUG [org.apache.http.impl.client.ClientParamsStack] 'http.protocol.handle-authentication': null The return message is "Access denied" because the "check session" on server failed. Please help me find out why these two connections' cookie are different. Thanks for your kindly help. Sincerely, Micky -----Original Message----- From: Roland Weber [mailto:[EMAIL PROTECTED] Sent: Thursday, March 06, 2008 1:02 AM To: HttpClient User Discussion Subject: Re: cookie or session-id is different from the same HttpClient connection?! Hello Micky, > I just use HttpsURLConnection.getHeaderField("Set-Cookie") to get a cookie > String, then I use HttpURLConnection.setRequestProperty("Cookie", cookie > String) for the next connection. > And it worked well. That surprises me. > It seems Sun HttpURLConnection didn't handle cookie internally. So it didn't work before you copied the cookie in your application. Interesting. >> HttpClient maintains a shared default session state for all >> connections. If you don't do something to prevent it, it will >> pick up the cookies that were previously set. > I think HttpClient should do this as you said too. But I don't know why it > doesn't work for my code now. Logging should help to find that out. You can also modify the code and put some System.out.println()s into interesting places, when the cookies for the request being sent are selected. > Should I handle the cookie management in the server? > The server is Struts on Tomcat, and I didn't do any additional action for > handling cookie because I think the server should handle it itself. If it's about a session cookie and your server-side application is a servlet or some other standard J2EE thing, you don't have to worry about session management. > When I print the cookie content from > HttpClient.getCookieStore().getCookies(), it shows as followings. > ---- > [version: 0][name: JSESSIONID][name: > 8C20EDB1D409B3AFCE1A1D25CCDE59CE][domain: 127.0.0.1][path: /agent][expiry: > null] > ---- This looks OK. However, it specifies both a domain "127.0.0.1" and a path "/agent". If your next request is NOT to 127.0.0.1, then the cookie will not be sent. The comparison is on the string level, so if the next request goes to "localhost" instead of "127.0.0.1", then it will NOT match. Also, if your next request does not go to a path starting with /agent, this cookie will not match. cheers, Roland --------------------------------------------------------------------- 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]
