This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes URL.openStream() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "URL.openStream()" Watch "URL.openStream()" New topic


Roger Shields

Joined: Nov 13, 2006
Posts: 4
I'm trying to read the contents of the reverse lookup page from at (Replace 8001234567 with any number.

But anyway, I get a with the message of
"Server returned HTTP response code: 403 for URL:".

But if you enter the url into your browser it brings up a web page.

Now my question, I'm wondering if anyone has any idea of what I can do to actually get the content of the page?
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2068
Have you tried HttpURLConnection?
Roger Shields

Joined: Nov 13, 2006
Posts: 4
Yes, tried both. I can enter most other URLs, like and it works fine. My best guess is that it is a problem with the user agent or something.
Henry Wong

Joined: Sep 28, 2004
Posts: 20380

An error code 403 is basically an "access denied" error code. It means that there is something with the request that the site doesn't like. Anyway, I took a quick look... and I guess there is a check to only work for supported browsers. So if you fake it out with something like this:

It seems to work.

[ January 20, 2007: Message edited by: Henry Wong ]

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
I agree. Here's the link:
subject: URL.openStream()
It's not a secret anymore!