java - How to use Apache HttpClient while the underlying connection is stateful? -


I'm doing a lot about using HTT client with multithreading. Most of them have suggested using ThreadSafeClientConnManager but my application must be entered in some host (login form page) so that HTTPPL can get an underlying statewide connection. What if ThreadSafeClientConnManager could hold the login level if multithreading?

Read the following sections from this page: 3.8 HTTP State Management and Execution Reference 3.9 Per User / Thread Status Management

And it may be that code you want:

  http client httpclient = new DefaultHttpClient (); // cookiestore cookieStore = new BasicCookieStore (); Make a local example of cookie store; // Create local HTTP references HttpContext localContext = new BasicHttpContext (); // Bind custom cookie store in local context. Local Contains. Settiet (ClientContactCOOKIE_STORE, CookieStore); HttpGet httpget = New HttpGet ("http://www.google.com/"); // Pass local reference as a parameter HttpResponse response = httpclient.execute (httpget, localContext);    

Comments