0
我打一個網址進行登錄如何用第一個網址的會話命中第二個網址?
public void hittingurl(){
String url = "http://test/login.jsp?username=hello&password=12345";
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
// optional default is GET
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
System.out.println("\nSending 'GET' request to URL : " + url);
System.out.println("Response Code : " + responseCode);
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
//print result
System.out.println(response.toString());
}
成功命中網址後登錄 當我打另一個URL
http://test/afterLogin.jsp
我不明白由於afterLogin.jsp輸出不能得到 se用戶名和密碼 的裂變valule我也是在login.jsp頁面
session.setAttribute("someparamValue", "value");
設置一個變量在會話有沒有辦法通過使用Java核心到的會話 內打第二網址第一個網址? 使afterLogin.jsp能夠得到會議的每一個值,我login.jsp中
讀取cookie,並在以下請求 – JEY
發送ü的意思是說,如果我使用session.setAttribute(設定值「someparamValue」,「value」); 然後我可以使用cookie讀取該值? –
您的登錄請求應該返回一個包含會話標識的cookie,這是您在以下請求中需要發送的內容。請閱讀http的工作方式。 https://en.wikipedia.org/wiki/HTTP_cookie – JEY