Solved

servlet code to return search results on the same page

Posted on 2004-10-04
2
960 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem with Pie chart in Jsp 20 249
Apache-Tomcat Single Sign On with NTLM/Kerberos on Windows 2008R2 3 278
spring AOP 6 94
iterator example remove 8 75
Check out this step-by-step guide for asking an anonymous question on Experts Exchange.
Invest in your employees with these five simple steps to improve employee engagement and retention.

739 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