A Front End to Various Search 
Engines: Code
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String searchString =
request.getParameter("searchString");
if ((searchString == null) ||
(searchString.length() == 0)) {
reportProblem(response, "Missing search string.");
return;
}
searchString = URLEncoder.encode(searchString);
String numResults =
request.getParameter("numResults");
...
String searchEngine =
request.getParameter("searchEngine");
53
Servlets
www.corewebprogramming.com
A Front End to Various Search 
Engines: Code (Continued)
SearchSpec[] commonSpecs =
SearchSpec.getCommonSpecs();
for(int i=0; i
SearchSpec searchSpec = commonSpecs[i];
if (searchSpec.getName().equals(searchEngine)) {
String url =
searchSpec.makeURL(searchString, numResults);
response.sendRedirect(url);
return;
}
}
reportProblem(response, 
"Unrecognized search engine.");
54
Servlets
www.corewebprogramming.com
27




  

Home

About Services Network Support FAQ Order Contact
 

Servlet Web Hosting

Our partners:Jsp Web Hosting Unlimited Web Hosting Cheapest Web Hosting  Java Web Hosting Web Templates Best Web Templates PHP Mysql Web Hosting Interland Web Hosting Cheap Web Hosting PHP Web Hosting Tomcat Web Hosting Quality Web Hosting Best Web Hosting  Mac Web Hosting 

Lunarwebhost.net  Business web hosting division of Vision Web Hosting Inc. All rights reserved