Home Answers Viewqa JSP-Servlet Google Search

 
 


Gopinath Ashokan
Google Search
2 Answer(s)      4 months ago
Posted in : JSP-Servlet

I have a textbox and submit button in my JSP page. On giving word in the textbox and click submit it should redirct to google search page and fetch all the results based on my input word automatically. JSP/Servlet code I need. Anyone can help me with explanation.

View Answers

January 24, 2013 at 6:02 PM


hi friend,

For this you can create a html page where you put a textbox and a submit button inside the form tag and write a Servlet for processing the redirect operation. In Servlet get the text what is entered into the textbox at html page then create a String with the value of google search page url and textbox value. And then pass this newly created String as the argument of sendRedirect() method.

An example is as follows : HTML page index.html is as follows :

    <p><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 <br>
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><br>
<html><br>
<head> <br>
<title>Google Search</title><br>
</head><br>
<body><br>
<form method="get" action="
GoogleSearch"><br>
<table><br>
<tr><br>
<td>Google Search </td><br>
<td><input type="text" 
name="search"/></td><br>
<td><input type="submit" 
value="search"/></td><br>
</tr><br>
</table><br>
</form><br>
</body><br>
</html></p>

And you can write the Servlet as follows :

package net.roseindia;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class GoogleSearch extends HttpServlet {

protected void doGet(HttpServletRequest request, 
HttpServletResponse response) throws ServletException, IOException {

String text = request.getParameter("search");
if(!((text) == null))
{
String url = 
"http://www.google.com/#hl=en&tbo=d&site=&source=hp&q="+text;
response.sendRedirect(url);
}
} 
protected void doPost(HttpServletRequest request, 
HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}

}

And the web.xml can be written as follows :

    <?xml version="1.0" encoding="UTF-8"?><br>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <br>
xmlns="http://java.sun.com/xml/ns/javaee" <br>
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" <br>
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" <br>
id="WebApp_ID" version="3.0"><br>
<display-name>googleSearch</display-name><br>
<welcome-file-list><br>
<welcome-file>index.html</welcome-file> <br>
</welcome-file-list><br>
<servlet><br>
<servlet-name>GoogleSearch</servlet-name><br>
<servlet-class>net.roseindia.GoogleSearch</servlet-class><br>
</servlet><br>
<servlet-mapping><br>
<servlet-name>GoogleSearch</servlet-name><br>
<url-pattern>/GoogleSearch</url-pattern><br>
</servlet-mapping><br>
</web-app><br>

For the detail tutorial how can we redirect to the google search using JSP visit the link Redirect to Google Search JSP


January 25, 2013 at 10:10 AM


Hi,

You can write a JSP page for this. Go through the link http://www.roseindia.net/jsp/redirect-google-search.shtml

this may helpful for you.

Thanks









Related Pages:
Google Search
Google Search  I have a textbox and submit button in my JSP page. On giving word in the textbox and click submit it should redirct to google search page and fetch all the results based on my input word automatically. JSP/Servlet
How to include website in google search?
How to include website in google search?  Does anyone has idea about how to include a website into Google Search?   Visit the given Google website link on how to oiptimize or submit your website to Google. http
Drop down for search textbox like google search
Drop down for search textbox like google search  I want drop down like google search (ie, when we type one letter then the word start with that are displayed). when the drop down list appear, then we can select one of word as our
Google Desktop Search
Google Desktop Search       GDSearch (Google Desktip Search) is an alternative File search... capabilities, this plug-in uses the Google Desktop Search Engine instead
Redirect to Google Search JSP
Redirect to Google Search JSP This tutorial explains you how can you crate a google search in your page. Redircting to google search means the text what you have entered into the textbox in your page, the google search should fetch
Dojo Google Web Search
Dojo Google Web Search        ... the google web search. That means user enter your text that have to be searched. This program search all content related to its. If you click on the filtered data
Dojo Google Blog Search
Dojo Google Blog Search      ... the google blog search. That means user enter your text that have to be searched...: Google Blog Search Here is the code of program: <html> <head>
add google map javascript
add google map javascript  How can i add google map using javascript in my web page?   Search for the " Google Maps Javascript API" it will allow you to embed the Google Map into your web Page
Google Ajax API
Google Ajax API  Hi, What is Google Ajax API? From where I can get in our application. Thanks   Hi, Google AJAX APIs is a JavaScript..., search, or feed-based Internet content into web applications/pages, organized
Google web Service (GWS)
using Internet. Whenever we have to search something we select Google for it. Google provides its search functionality as its web service...Google web Service (GWS)      
search program
links after google search...plzz help...search program  i m writing program which takes company names from databse...serch on google...n try to find the best match WEBSITE...of company name
Web Search
Web Search         The Web Search plugin for Eclipse allows you to search for selected text on the Web using Google, Yahoo, or Microsoft Live Search. The plugin supports
Google maps GPS tracking
. But like search engine, Google has given this facility for free too. Though...Now you can pinpoint your position with the aid of Google map that is now... enabled on Google maps. Recently released GE 4 Beta (December 16) has a compatible
Turnhout
Turnhout Turnhout1 is a eclipse plugin to search google Whats New Added preference to change the search engine. Default is Google. Added preference to add a keyword (e.g. Java) to search string for more
SEO and Search Engines,Best Search Engines on Web,What is Search Engine
in the search result page. Best Search Engine Google.com: Google... technology. Now ad days the search engine leader is Google, with many services like image search, email, chat, bogglers etc. Google provides best clutter free
Search Engine - Java Beginners
Search Engine  Hello Sir, I am new jsp, also i need search engine coding from the local computer or database only.pls send the jsp with mysql codes.I dont know how to create a search engine(like google) in local computer
JSP search engine - JSP-Servlet
JSP search engine  Hi! In my project i have a concept of search engine which has to search in google and display the results in my page. My PM told me use GOOGLE API for search engine. I am developing applicatin in JSP. Can
Finding searching phrase of a search engine
Finding searching phrase of a search engine  how to find out searching phrase of a search engine..? like, if visitors enter the keyword to google, is is any possible to get that keyword
Major Search Engines List
search engines are Google, Yahoo and other popular engines. ... site is being found on sites such as the Google Directory, AOL search... Major Search Engine Lists   
search
search  how to develop search box and how to retrive data from database..   Please visit the following link: Search box
Auto Search box using ajax
Auto Search box using ajax   Hi , i want to implement auto search box functionality like google and linkedin using ajax,jsp,servlet, javascript etc.when the value appears on the textbox then we should also be able to select
SEARCH
SEARCH  how can we do search in jsp...? option for search criteria like name and DOB...   Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
Submitting Web site to search engine
search engines by visiting the major search engines (yahoo, google... Registering Your Web Site To Search Engines.... 85% of Internet users find sites through search engines, so each search
Google AJAXSLT
Google AJAXSLT       Google AJAXSLT is a Javascript framework for performing XSLT transformations, as well as XPath queries utilizes Backbase AJAX engine - cross browser compatible Read
Developing Search Engine in Java
, the spider search it against the index and retrieves the results accordingly. Google... Developing Search Engine in Java       In this section we will discuss about the search engine
about google map
about google map  how to add google map in website
about google map
about google map  how to add google map in website
Auto complete of word search using ajax with java
like google search. Please help. Thanks in advance...Auto complete of word search using ajax with java  I want to display the list of words when I type the first letter of the word in a text box. I am
Auto complete of word search using ajax with java
like google search. Please help. Thanks in advance...Auto complete of word search using ajax with java  I want to display the list of words when I type the first letter of the word in a text box. I am
ApplicationDevelopment Using Google Map
ApplicationDevelopment Using Google Map  I want application using google map please guide me how can i develop
Google Map Integration - Ajax
Google Map Integration  Hi All, I am working on a vehicle tracking system project. I have to read data from sql server database and map the vehicle position in google map. I need to use ajax as the data is updated in every
Top 10 SEO Mistakes,Common Mistakes in Search Engine Optimization,Search Engine Marketing Mistakes
Search Engine Mistakes - Search Engine Optimization Mistakes... design good website and promotes in the search engines for getting visitors... content but they do not rank well on the search engine results. These low placements
Source Code for Search Engine Project in java - Java Beginners
Source Code for Search Engine Project in java  Hello Sir ,I want Java Project for Search Engine(like google),How I can Make it,Plz Give Me Complete Source Code Of Search Engine Project in Java.  Hi Friend, Please
license for google maps - iPhone SDK
license for google maps - iPhone SDK  Do i need a license to display the locations on google map in my iPhone application
Google Gadget Eclipse plugin
Google Gadget Eclipse plugin       Overview EGadget Plugin is ued to integrate any Google... Google Gadget into your favorite Eclipse IDE Built-in three Google Gadget
LangTags GCSP
LangTags GCSP LangTags GCSP is a Eclipse RCP Tool for Google CodeSearch. GCSP Feathers: Run as Eclipse RCP or Eclipse Plugin. Display more results for one search. Search Java SubClass Search C# SubClass Filter C
New Releases
;   Hibernate Search 3.0 available Now the developers can take advantage of advanced search capabilities like Google without extra infrastructure coding with the help of Hibernate Search 3.0. This hibernate search
JavaScript google map API example.
JavaScript google map API example.  How to Use Google Maps API in JavaScript?   Google Maps- A map is a way of representation of your route... routes, a road map shows you road, street information. In the same way google map
Google Adsense Tutorial
Google Adsense Tutorial     ... setup Google Adsense Account for your web site and start earning money from your... are good option for earning money from web site. Google Adsense is top program
Google Zeitgeist-Trends-maps mashup
Google Zeitgeist-Trends-maps mashup       A usable mashup of google trends and zeitgeist most popular on google maps to show _where_ what is most popular Read full Description
get latitude and longitude from google maps
get latitude and longitude from google maps  How to get the latitude and longitude from google maps
Search index
Search index  how to write code for advanced search button
Search Engine Optimization (SEO)
is to get listed. The major leading search engines are Google, Yahoo and Microsoft...Search Engine Optimization (SEO) Search engine optimization, also known... of their ranking by web search engines. Or we can say that, it is the way
linear search
linear search  write a program to find string using linear search
to make a google map point to user defined location
to make a google map point to user defined location  Hi, i wish to develop an google map,that takes the input from a form(city,area &Country) and points the location in google map.so how do i do it? wen i press the submit
SEARCH AND SORT
SEARCH AND SORT  Cam any one provide me the code in java that : Program to search for MAX,MIN and then SORT the set using any of the Divide and conquer method
SEARCH PAGE
SEARCH PAGE  search page:option for search criteria like name and DOB will be asked.on entering the detail,data matching search criteria will be displayed..criteria can be both or any one of them.. can you send code
Google Web Toolkit
Google Web Toolkit       Google Web Toolkit (GWT) is a Java software development framework that makes writing AJAX applications like Google Maps and Gmail easy for developers who don't
search for a name
search for a name  Search for a name Write a program to accept an array of names and a name and check whether the name is present in the array. Return the count of occurrence. Use the following array as input {?Dave?, ?Ann
Search Engine
Search Engine  I have gone through the below mentioned link document to create search engine and fetch the data from mysql database.But i am getting errors. http://www.roseindia.net/sql/mysql-table/sql-search.shtml Error: Notice

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.