Google Search

Ads
 

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 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

Ads









Related Tutorials/Questions & Answers:
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
ModuleNotFoundError: No module named 'google-search'
ModuleNotFoundError: No module named 'google-search'  Hi, My... 'google-search' How to remove the ModuleNotFoundError: No module named 'google-search' error? Thanks   Hi, In your python
Advertisements
ModuleNotFoundError: No module named 'search-google'
ModuleNotFoundError: No module named 'search-google'  Hi, My... 'search-google' How to remove the ModuleNotFoundError: No module named 'search-google' error? Thanks   Hi, In your python
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
ModuleNotFoundError: No module named 'Google-Images-Search'
ModuleNotFoundError: No module named 'Google-Images-Search'  Hi...: No module named 'Google-Images-Search' How to remove the ModuleNotFoundError: No module named 'Google-Images-Search' error? Thanks   Hi
ModuleNotFoundError: No module named 'Google-Search-API'
ModuleNotFoundError: No module named 'Google-Search-API'  Hi, My... named 'Google-Search-API' How to remove the ModuleNotFoundError: No module named 'Google-Search-API' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'Google-Search-API'
ModuleNotFoundError: No module named 'Google-Search-API'  Hi, My... named 'Google-Search-API' How to remove the ModuleNotFoundError: No module named 'Google-Search-API' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'google-search-cli'
ModuleNotFoundError: No module named 'google-search-cli'  Hi, My... named 'google-search-cli' How to remove the ModuleNotFoundError: No module named 'google-search-cli' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'google-search-cli'
ModuleNotFoundError: No module named 'google-search-cli'  Hi, My... named 'google-search-cli' How to remove the ModuleNotFoundError: No module named 'google-search-cli' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'google-search-client'
ModuleNotFoundError: No module named 'google-search-client'  Hi...: No module named 'google-search-client' How to remove the ModuleNotFoundError: No module named 'google-search-client' error? Thanks   Hi
ModuleNotFoundError: No module named 'google-search-client'
ModuleNotFoundError: No module named 'google-search-client'  Hi...: No module named 'google-search-client' How to remove the ModuleNotFoundError: No module named 'google-search-client' error? Thanks   Hi
ModuleNotFoundError: No module named 'google-search-results'
ModuleNotFoundError: No module named 'google-search-results'  Hi...: No module named 'google-search-results' How to remove the ModuleNotFoundError: No module named 'google-search-results' error? Thanks   Hi
ModuleNotFoundError: No module named 'Google-Search-API'
ModuleNotFoundError: No module named 'Google-Search-API'  Hi, My... named 'Google-Search-API' How to remove the ModuleNotFoundError: No module named 'Google-Search-API' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'google-search-cli'
ModuleNotFoundError: No module named 'google-search-cli'  Hi, My... named 'google-search-cli' How to remove the ModuleNotFoundError: No module named 'google-search-cli' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'google-search-client'
ModuleNotFoundError: No module named 'google-search-client'  Hi...: No module named 'google-search-client' How to remove the ModuleNotFoundError: No module named 'google-search-client' error? Thanks   Hi
ModuleNotFoundError: No module named 'google_search_module_alt'
ModuleNotFoundError: No module named 'google_search_module_alt'  Hi...: No module named 'google_search_module_alt' How to remove the ModuleNotFoundError: No module named 'google_search_module_alt' error? Thanks  
ModuleNotFoundError: No module named 'google-search-results'
ModuleNotFoundError: No module named 'google-search-results'  Hi...: No module named 'google-search-results' How to remove the ModuleNotFoundError: No module named 'google-search-results' error? Thanks   Hi
ModuleNotFoundError: No module named 'google-search-results-serpwow'
ModuleNotFoundError: No module named 'google-search-results-serpwow'  ...: No module named 'google-search-results-serpwow' How to remove the ModuleNotFoundError: No module named 'google-search-results-serpwow' error
ModuleNotFoundError: No module named 'Python-Google_Image_Search'
ModuleNotFoundError: No module named 'Python-Google_Image_Search'  Hi...: No module named 'Python-Google_Image_Search' How to remove the ModuleNotFoundError: No module named 'Python-Google_Image_Search' error? Thanks
ModuleNotFoundError: No module named 'Python-Google_Image_Search'
ModuleNotFoundError: No module named 'Python-Google_Image_Search'  Hi...: No module named 'Python-Google_Image_Search' How to remove the ModuleNotFoundError: No module named 'Python-Google_Image_Search' error? Thanks
ModuleNotFoundError: No module named 'tap-google-search-console'
ModuleNotFoundError: No module named 'tap-google-search-console'  Hi...: No module named 'tap-google-search-console' How to remove the ModuleNotFoundError: No module named 'tap-google-search-console' error? Thanks  
ModuleNotFoundError: No module named 'tap-google-search-console'
ModuleNotFoundError: No module named 'tap-google-search-console'  Hi...: No module named 'tap-google-search-console' How to remove the ModuleNotFoundError: No module named 'tap-google-search-console' error? Thanks  
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
Top 10 Ways to Increase Google Search Hits
Top 10 Ways to Increase Google Search Hits In deliberating here on the top 10 ways to increase Google search hits first of all one must understand how search... search engines who will not agree with the dominance of Google as the world's most
Top 20 SEO Techniques for Google Search Ranks
. Though in presenting top SEO techniques for Google search ranks we are most likely... tools and techniques. Here is our pick on top SEO techniques for Google search... to search ranks in Google or for that matter any other search engine. Putting
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
search  how to develop search box and how to retrive data from database..   Please visit the following link: Search box
Google Penguin 3.0 Launched
release of Google Penguin search engine technology. Last month Google's 27th... that the Penguin 3.0 is released and the Google Search is being updated with new...Google Penguin 3.0 Launched nearly after year year of previous Google Penguin
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
Google says Start Searching India
Google has started a new campaign for Indian people to persuade them to search everything and anything on its search engine. Google aims to simplify.... Google will provide the search results of your queries in the form

Ads