Servlet会话由cookie支持。您基本上需要
Set-cookie从第一个请求的响应中获取所有标头,然后将这些
name=value对作为
cookie后续请求的标头传回。
目前尚不清楚您使用的是哪种HTTP客户端,但是如果使用
java.net.URLConnection,则可以使用
java.net.cookieHandler。
// First set the default cookie manager.cookieHandler.setDefault(new cookieManager(null, cookiePolicy.ACCEPT_ALL));// All the following subsequent URLConnections will use the same cookie manager.URLConnection connection = new URL(url).openConnection();// ...connection = new URL(url).openConnection();// ...connection = new URL(url).openConnection();// ...



