title: How can I put a cookie in Jersey RESTful webservice?
body: <p>I would like to put a cookie from "PUT webservice result" to "POST webservice" by Jersey API.</p>
  
  <p>Here is my code</p>
  
  <pre><code>WebResource service1 = client.resource("http://test.com");
  
  ClientResponse logResponse = service1.accept(MediaType.APPLICATION_XML).put(ClientResponse.class, "&lt;?xml version='1.0'?&gt;&lt;test&gt;1&lt;/test&gt;");
  
  WebResource service2 = client.resource("http://test.com/post");
  WebResource.Builder builder = service2.getRequestBuilder();
  
  for(Cookie c : logResponse.getCookies())
  {
  if(c.getName().equals("SESSID"))
      builder = builder.cookie(c);
  }
  
  ClientResponse test = builder.accept(MediaType.TEXT_XML).post(ClientResponse.class, "&lt;?xml version='1.0'?&gt;&lt;post&gt;abc&lt;/post&gt;");
  </code></pre>
  
  <p>I thought If I set a cookie by "Builder.cookie" method, the cookie value will be added on the header of request for POST web service.</p>
  
  <p>So, in this case, the cookie from the PUT web service will be set into POST web service.</p>
  
  <p>However, if I check the header(by <code>logResponse.getHeaders()</code> and <code>test.getHeaders()</code> methods) after two web services, first PUT web service has the Cookie but second POST web service does not have any cookies.</p>
  
  <p>Anybody can help me to keep a cookie between two web services?</p>