下面是我使用的是开放的URLConnection的另一个webapllication代码
try {
URL url = new URL("https://mySecondWebApp/Cart");
HttpsURLConnection conn1 = (HttpsURLConnection) url.openConnection();//line1
conn1 .connect();//line 2 does not establishes the connection
conn1.getInputStream();// line 3 works which means that i get control to my app2 in debugger.But this also passes the control to IOException stating error java.io.FileNotFoundException: https://mySecondWebApp/Cart
}
catch (MalformedURLException e) {
log.error("MalformedURLException" + e);
}
catch (IOException e) {
log.info("getting IO error");
}
我没有得到为什么2号线不建立与APP 2,而3号线确实连接? 第二件事就是为什么我得到3行后的文件NOTFOUND例外,即使它成功地连接到APP 2,我想avoid.My意图只是为了建立APP2连接,使我得到APP2我的Java代码内部人控制