Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6373025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:18:46+00:00 2026-05-25T01:18:46+00:00

Jsoup has 2 html parse() methods: parse(String html) – As no base URI is

  • 0

Jsoup has 2 html parse() methods:

  1. parse(String html) – “As no base URI is specified, absolute URL
    detection relies on the HTML including a tag.”
  2. parse(String html, String baseUri) – “The URL where the HTML
    was retrieved from. Used to resolve relative URLs to absolute URLs,
    that occur before the HTML declares a tag.”

I am having a difficulty understanding the meaning of the difference between the two:

  1. In the 2nd parse() version, what does “resolve relative URLs to absolute URLs, that occur
    before the HTML declares a <base href> tag” mean? What if a
    <base href> tag never occurs in the page?
  2. What is the purpose of absolute URL detection? Why does Jsoup need
    to find the absolute URL?
  3. Lastly, but most importantly: Is baseUri the full URL of HTML page
    (as phrased in original documentation) or is it the base URL of
    the HTML page?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:18:46+00:00Added an answer on May 25, 2026 at 1:18 am

    It’s used for among others Element#absUrl() so that you can retrieve the (intended) absolute URL of an <a href>, <img src>, <link href>, <script src>, etc. E.g.

    for (Element link : document.select("a")) {
        System.out.println(link.absUrl("href"));
    }
    

    This is very useful if you want to download and/or parse the linked resources as well.


    In the 2nd parse() version, what does “resolve relative URLs to absolute URLs, that occur before the HTML declares a <base href> tag” mean? What if a <base href> tag never occurs in the page?

    Some (poor) websites may have declared a <link> or <script> with a relative URL before the <base> tag. Or if there is no means of a <base> tag, then just the given baseUri will be used for resolving relative URLs of the entire document.


    What is the purpose of absolute URL detection? Why does Jsoup need to find the absolute URL?

    In order to return the right URL on Element#absUrl(). This is purely for enduser’s convenience. Jsoup doesn’t need it in order to successfully parse the HTML at its own.


    Lastly, but most importantly: Is baseUri the full URL of HTML page (as phrased in original documentation) or is it the base URL of the HTML page?

    The former. If the latter, then documentation would be lying. The baseUri must not to be confused with <base href>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using JSoup to parse lyrics and it has been great until
Jsoup is a very convenient tool to parse html and used as a basic
i am using java with jsoup to parse a website, trouble is , alot
i'm using JSoup to parse a webpage like this , and make it into
I'm trying to do something similar to: Jsoup: How to get all html between
I extract some information from the html sourcecode of different pages with jsoup. Most
I am trying to select, using Jsoup , a <div> that has multiple classes:
I'm making html widget for websites. Let's say, it will display current stock indexes.
I'm stuck on a clients host that has medium trust setup which blocks cross
This is the beginning -- I have a file on disk which is HTML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.