关于URLconnection问题
下面一段代码
先建立了一次可靠连接,然后又进行了一次请求连接,这两次连接是否相互关联,如果这是两个互相独立的连接,怎样才能让第二请求并入第一次连接
//第一次连接
URL url = new URL("http://xxxx.xxxx.xx.cn/login.do");
URLConnection connection = url.openConnection();
// 设置通用的请求属性
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
connection.setUseCaches(true);
connection.setDoInput(true);
connection.setDoOutput(true);
// 建立实际的连接
connection.connect();
//第二次连接
ImageIcon newicon = new ImageIcon(new URL("http://xxxx.xxxx.xx.cn/getRandomImage.do?"+new Date()));