user1792052
user1792052

Reputation: 45

How to work around Http 403 error with Java?

Many websites do not allow directory browsing. They want you to navigate from and in the webpages of that site. So for example if the page contains an image, you can only view the image by loading the whole page. When you paste the image location into the browser, you get the 403. Same situation when you try to access that image using URLConnection.

My question is, is there anyway to work around this? I.E. trick the server into thinking that our java access request comes from the page (knowing the url of the page that contains the item we want to access)?

Thanks, Peter.

Upvotes: 1

Views: 510

Answers (1)

Leo
Leo

Reputation: 56

You can spoof the referer. It is used by servers showing this behaviour to know if you've come from eg a search engine.

http://www.jguru.com/faq/view.jsp?EID=257742 shows one implementation of it in Java.

Upvotes: 3

Related Questions