External Libraries

Jsoup set referrer example

Jsoup set referrer example shows how to set Jsoup referrer. Example also shows Jsoup default referrer as well as how to set Jsoup referrer of your choice.

What is the Jsoup default referrer?

Jsoup uses empty referrer header while connecting to the URL requested. This can be verified by running below given code.


Note: You can check your referrer by visiting https://www.whatismyreferer.com website.

How to set Jsoup referrer (referer)?

Some of the websites do not work if “referer” header is not sent along with the request. You may get HTTP 403 error while accessing those websites using Jsoup, since Jsoup pass empty value for the “referer” header by default.

To set referrer or “referer” header, you can use referrer method of Connection class.

This method sets the HTTP referer header of the request.

Below given example shows how to set Jsoup referer to “http://www.google.com”.


See Also:

Set Jsoup user agent example

Please let us know your views in the comments section below.

Want to learn quickly?
Try one of the many quizzes. I promise you will not be disappointed.


About the author



rahimv has over 15 years of experience in designing and developing Java applications. His areas of expertise are J2EE and eCommerce. If you like the website, follow him on Facebook, Twitter or Google Plus.

Add Comment

Your email address will not be published. Required fields are marked *