佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > jsp搜索引擎

jsp搜索引擎

熱門標(biāo)簽:科大訊飛語音識別系統(tǒng) Linux服務(wù)器 銀行業(yè)務(wù) 團(tuán)購網(wǎng)站 Mysql連接數(shù)設(shè)置 服務(wù)器配置 阿里云 電子圍欄

package coreservlets; 



import java.io.*; 
import javax.servlet.*; 
import javax.servlet.http.*; 
import java.net.*; 




public class SearchEngines extends HttpServlet { 
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; 

// The URLEncoder changes spaces to "+" signs and other 
// non-alphanumeric characters to "%XY", where XY is the 
// hex value of the ASCII (or ISO Latin-1) character. 
// Browsers always URL-encode form values, so the 
// getParameter method decodes automatically. But since 
// we"re just passing this on to another server, we need to 
// re-encode it. 
searchString = URLEncoder.encode(searchString); 
String numResults = request.getParameter("numResults"); 
if ((numResults == null) 

(numResults.equals("0")) 

(numResults.length() == 0)) { 
numResults = "10"; 

String searchEngine = 
request.getParameter("searchEngine"); 
if (searchEngine == null) { 
reportProblem(response, "Missing search engine name."); 
return; 

SearchSpec[] commonSpecs = SearchSpec.getCommonSpecs(); 
for(int i=0; icommonSpecs.length; 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."); 




private void reportProblem(HttpServletResponse response, 
String message) 
throws IOException { 
response.sendError(response.SC_NOT_FOUND, 
"H2>" + message + "/H2>"); 




public void doPost(HttpServletRequest request, 
HttpServletResponse response) 
throws ServletException, IOException { 
doGet(request, response); 


您可能感興趣的文章:
  • jsp網(wǎng)頁搜索結(jié)果中實(shí)現(xiàn)選中一行使其高亮
  • jsp源碼實(shí)例4(搜索引擎)
  • php+ajax做仿百度搜索下拉自動提示框(有實(shí)例)
  • asp+ajax仿google搜索提示效果代碼
  • jquery創(chuàng)建一個ajax關(guān)鍵詞數(shù)據(jù)搜索實(shí)現(xiàn)思路
  • asp.net和ajax實(shí)現(xiàn)智能搜索功能代碼
  • ThinkPHP實(shí)現(xiàn)ajax仿官網(wǎng)搜索功能實(shí)例
  • php+ajax實(shí)時輸入自動搜索匹配的方法
  • ajax Suggest類似google的搜索提示效果
  • Ajax+Servlet+jsp顯示搜索效果

標(biāo)簽:棗莊 衢州 江蘇 大理 萍鄉(xiāng) 廣元 衡水 蚌埠

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《jsp搜索引擎》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    陆丰市| 荆门市| 化隆| 怀安县| 尤溪县| 静乐县| 法库县| 读书| 大悟县| 军事| 扶风县| 都江堰市| 寿宁县| 建水县| 原平市| 册亨县| 南投县| 开封县| 武邑县| 荣昌县| 凉城县| 博兴县| 沙河市| 文安县| 高平市| 乐业县| 枣强县| 南华县| 泸溪县| 司法| 都安| 临朐县| 孟津县| 平凉市| 扬中市| 东宁县| 刚察县| 淮北市| 佛坪县| 拜泉县| 海口市|