首页 > 代码库 > Java后台创建新的URl,如何继承浏览器session
Java后台创建新的URl,如何继承浏览器session
URL url = new URL(postURL);
HttpURLConnection connection = (HttpURLConnection) url
.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
System.out.println(request.getSession().getId());
//String session_value=http://www.mamicode.com/connection.getHeaderField("Set-Cookie");
//String[] sessionId = session_value.split(";");
connection.addRequestProperty("Cookie", "JSESSIONID=" + request.getSession().getId());
/*HttpClient client=new HttpClient();
PostMethod pmethod=new PostMethod(url.toString());
pmethod.addRequestHeader("Cookie", "JSESSIONID=" + request.getSession().getId());
client.executeMethod(pmethod);*/
connection.connect();
InputStream in = new BufferedInputStream(
connection.getInputStream());
Java后台创建新的URl,如何继承浏览器session