Solved

servlet code to return search results on the same page

Posted on 2004-10-04
2
953 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
ID: 12219031
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
In 2017, ransomware will become so virulent and widespread that if you aren’t a victim yourself, you will know someone who is.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

920 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