I have two web application hosted on two different tomcat instances say T1 and T2. I am making below method
in a java class on T1 to retrieve java object named as User from T2
private Properties checkContentChanges() {
Properties reply = null;
try {
String urlStr = "http://myApp:8080/wiki/bin/view/?checkContent=true&Name=dummy;"
URL url;
reply = new Properties();
try {
url = new URL(urlStr);
//sun.net.www.protocol.http.HttpURLConnection conn = (sun.net.www.protocol.http.HttpURLConnection) url
.openConnection();//line 1
URLConnection conn = url
.openConnection();// line 2
conn.addRequestProperty("User-Agent",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)");
InputStream is = conn.getInputStream();// line3
reply.load(conn.getInputStream());
}
catch (MalformedURLException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();//line 5
}
}
But at line 3 i am getting error java.io.IOException: Server returned HTTP response code: 403 for URL: http://myApp:8080/wiki/... Though the call goes to method on T2 and
it returns expected user object. So T2 side works fine but once it return i get above exception at line 5 at T1 . I tried line 1 too instead of line 2 but same exception?
Though thru the brower same url works fine
Posted at http://stackoverflow.com/questions/9495093/getting-java-io-ioexception-server-returned-http-response-code-403-for-url but no response as of now. Thanks in advance.