URL访问页面并获取页面返回的值

URL url = new URL(path+"/integral/interface/checkCardExist.jsp?card="+userPin+"&pwd="+pwd);
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); 

//设置成post提交 

connection.setRequestMethod("POST");
connection.connect();
   
InputStream is =  connection.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String result = "";
//这里接的返回值是页面out.print()输出的值

while (br.readLine() != null) {
  result += br.readLine();
}
if("(0)".equals(result))
  throw new Exception("用户名密码错误!");

你可能感兴趣的:(jsp)