Here is the code i am using the open the URLConnection to another 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");
}
I am not getting why line 2 does not establish the connection with app2 while line 3 does? second thing is why i get the file notfound exception after line 3 even though it sucessfully connect to app2 which i want to avoid.My intention is just to establish the connection to app2 so that i get control inside my java code of app2