Java后台创建新的URl,如何继承浏览器session
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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=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的主要内容,如果未能解决你的问题,请参考以下文章