You will get a NullPointerException whenever you use a variable, method (, or other expression) as if it had a non null value when it is really null. Commonly such usage involves array access with [] or the "dot" operator. For example:
String[] foo;
foo[42] = "?"; // bad []! foo is null
foo = new String[666];
System.out.println(foo[42].length()); // bad dot! foo[42] is null
foo[42] = "?"
System.out.println(foo[42].length()); // success!
In the line "if(content.hasText()){System.out.println("res ult is " + content.text());" the only thing you use the "dot" operator on is
content. So my guess would be that
content is null. You can check this with:
Element content = doc.getElementById("navbar");
System.out.println("About to get the content: content=" + content);
if(content.hasText()){System.out.println("result is " + content.text());}
else System.out.println("nothing!");
Once (or if) you verify that
content is the culprit you have to figure out why doc.getElementById() returned null. This may involve checking the API docs for getElementById() to see under what conditions it returns null.