Solved

servlet code to return search results on the same page

Posted on 2004-10-04
2
951 Views
Last Modified: 2008-01-09
I have code in my servlet which getting search string from client and redirecting this search string to Google ( using response.sendRedirect(URL) ) to run the search.

basically I am redirecting to following URL :

"http://www.google.com/search?q=" + searchString

When I am doing a redirect, browser returning google website with search results.

I'd like my servlet to retrieve search results from Google and  display them on my own page, but not on Google page.

Does anyone know how to do that ?

I really appreciate your help.

Thanks.  
0
Comment
Question by:egorelik
2 Comments
 
LVL 4

Accepted Solution

by:
gdrnec earned 100 total points
Comment Utility
There are two ways that I know of. The first is much easier. Google has a java api that you can use that will return results as objects to your java code. I have used it in the past and it works a treat http://www.google.com/apis/

The other way is far more complicated and involves a good deal of parsing but if instead of redirecting, you actually open the URL, get its inputStream and parse the HTML results, you can scrape the search results off the page and then do what you want with them.

I suggest the API.

Geoff
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
In this article, I will show you HOW TO: Create your first Windows Virtual Machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, the Windows OS we will install is Windows Server 2016.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now