から Cookie を取得し、DefaultHttpClient
それらを HtmlUnit の に渡しWebClient
、リクエストを送信する必要があります。
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.*;
import org.apache.http.impl.client.DefaultHttpClient;
import com.gargoylesoftware.htmlunit.*;
import com.gargoylesoftware.htmlunit.util.*;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
HttpClient apacheClient = new DefaultHttpClient();
HttpResponse apacheResponse;
HttpGet apacheGet;
WebClient htmlUnitClient = new WebClient();
WebRequest htmlUnitRequest;
HttpUriRequest hur = new HttpGet("http://..");
apacheResponse = apacheClient.execute(hur);
// Here I need to get cookies from apacheClient and set them for the next request done with htmlUnitClient
HtmlPage page = htmlUnitClient.getPage("http://..");
また、クッキーを何らかのコンテナ内に保持したいと思います。これは可能ですか?