Apache HttpClient 4.0.3 - how do I set cookie with sessionID for POST request?

后端 未结 4 1015
梦毁少年i
梦毁少年i 2020-11-27 02:38

can you tell me how to store jsessionid in cookie, so it can be passed to the servlet with post request? I\'m using Apache HttpClient version 4.0.3. All the solutions I\'ve

4条回答
  •  醉梦人生
    2020-11-27 03:14

    I did it by passing the cookie through the HttpContext:

    HttpContext localContext = new BasicHttpContext();
    
    localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
    
    response = client.execute(httppost, localContext);
    

提交回复
热议问题