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]

Reply via email to