Hi, Never mind my email. I was posting to an incorrect URL that is why, I was not able to share sessions with any subsequent posts, using the same httpclient instance.
Sincerely, -Mohsin -----Original Message----- From: Beg, Mohsin [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 13, 2004 1:22 AM To: '[EMAIL PROTECTED]' Subject: How to share a single http session across multiple http posts Hi, I have a need where I need to do multiple separate posts to a URL but need all the posts to share the same session context. I am able to do the initial login to a URL successfully as shown below. It is unclear to me how to "reuse" any instances or set some parameters to make sure that all subsequent posts are for the same session. The behavior I need is approximately like that of a browser. Can someone provide any pointers ? Sincerely, -Mohsin ps: My webserver is running jetty4.2.19 on WinXP under jdk1.4.2 HttpClient httpClient = new HttpClient(); httpClient.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT, "http"); httpClient.getState().setCookiePolicy(CookiePolicy.COMPATIBILITY); NameValuePair msgTransaction = new NameValuePair("XML", LOGIN_XML); PostMethod postMethod = new PostMethod(SERVER_URL); postMethod.setRequestHeader("Content-type", PostMethod.FORM_URL_ENCODED_CONTENT_TYPE); postMethod.setUseExpectHeader(true); postMethod.setHttp11(false); postMethod.addParameter(msgTransaction); try { int statusCode = httpClient.executeMethod(postMethod); String response = new String(postMethod.getResponseBody(), postMethod.getResponseCharSet()); System.out.println(response); } catch (Exception e) { e.printStackTrace(); } finally { postMethod.releaseConnection(); } --------------------------------------------------------------------- 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]