Let me also tell what i am trying to do here is
My first web application wants to get some information from wiki. So it
sends a call to Wiki and on wiki side i get it in to checkAuth method of
MyClass Extends XWikiAuthServiceImpl. Here return type of checkAuth
method is xwikiuser so i am returning info as
return new XWikiUser("MyInformation"); But in my web application at T1 i
get exception as Getting java.io.IOException: Server returned HTTP response
code: 403 for URL. Hope it clarifies. May be i can do it in some other way
in xwiki. Looking for your valuable inputs.
---------- Forwarded message ----------
From: mohit gupta <motgupta(a)gmail.com>
Date: Wed, Feb 29, 2012 at 3:28 PM
Subject: Getting java.io.IOException: Server returned HTTP response code:
403 for URL… But thru browser it works fine?
To: XWiki Users <users(a)xwiki.org>
I have two web application hosted on two different tomcat instances say T1
and T2(xwiki is on T2). I am making below method
in a java class on T1 to retrieve java xwikiUserObject named 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? As i tried to find it out on net especially on
http://en.wikipedia.org/wiki/HTTP_403 looks like its due to some config on
xwiki side. Not getting whats the exact issue?
Though thru the brower same url works fine
.