Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

servlet code to return search results on the same page

Posted on 2004-10-04
2
Medium Priority
?
970 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 400 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

If you’re involved with your company’s wide area network (WAN), you’ve probably heard about SD-WANs. They’re the “boy wonder” of networking, ostensibly allowing companies to replace expensive MPLS lines with low-cost Internet access. But, are they …
What we learned in Webroot's webinar on multi-vector protection.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

688 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