I found a solution here but It is in java format and I want to use it in a jsp file internally. My code is like this but it shows null when loaded in localhost tomcat:
<html>
<head>
<title>Number of Google Search Results</title>
</head>
<body>
<%@ page import="org.jsoup.Jsoup" %>
<%@ page import="org.jsoup.nodes.Document" %>
<%@ page import="org.jsoup.nodes.Element" %>
<%@ page import="org.jsoup.select.Elements" %>
<%
String url = "https://www.google.com/search?q=query";
Document document = Jsoup //
.connect(url) //
.userAgent("Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)") //
.get();
Element divResultStats = document.select("div#result-stats").first();
%>
<% out.print(divResultStats); %>
</body>
</html>