通过参数传递,如:String userID = "admin";
URL url = new URL("http://localhost/1.jsp?userID=" + userID);//在另一个页面里取出参数,然后判断是否为null
String userID = (String)session.getValue("userID");if (userID == null)
{
//在这里直接进入错误页面!!
}
URL url = new URL("http://localhost/1.jsp?userID=" + userID);//在另一个页面里取出参数,然后判断是否为null
String userID = (String)session.getValue("userID");if (userID == null)
{
//在这里直接进入错误页面!!
}
String url="http://....."+";jsessionid="+sessionid;
如果不知道的话就
String url=response.encodeURL("http://....");
只有cookies被禁用了才会重写url.
//也可以这么用
试了也不行。URL url = new URL(".......");
String sessionid = url.openConnection().getHeaderField("Set-Cookie");得到一个 ASPSESSIONIDAAQRSBSA=COMBAKIBFHLCKKMFALGKECCL; path=/ 这样的字串。我是想InputStream in = url.openStream();后read()这个页面内容。所以不能用response.encodeURL()这样。如何把sessionid发送到这个页面呢?谢谢。
HttpURLConnection huc= (HttpURLConnection) url.openConnection();
huc.setRequestProperty("Cookie", sessionid);