Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTP response code 403 error

Status
Not open for further replies.

pratibha14

Technical User
Mar 2, 2004
30
0
0
Hi..

I want the source code of a web page. So, I wrote following code:

URL u = new URL("URLConnection uc = u.openConnection();
uc.connect();
InputStream in = uc.getInputStream();

But it returns this error
"java.io.IOException: Server returned HTTP response code: 403 for URL:
If i change URL from google search to yahoo search or MSN search.... " then it works without any error.

Can anyone tell me how to resolve it?

Thanks
 
I think this way of reading home page cannot undergo page redirect. Therefore, this way can get page without being redirect.
 
HTTP status 403 means that the server has understood the request, but refuses to fulfill it.

I expect this is because the agent header is not set to mimic a "normal browser", so google refuses on grounds that its probably some programme attempting to harvest information (which would be correct !).

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top