濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > jsp源碼實(shí)例4(搜索引擎)

jsp源碼實(shí)例4(搜索引擎)

熱門標(biāo)簽:長(zhǎng)春回?fù)芡夂粝到y(tǒng)廠家 山東智能云外呼管理系統(tǒng) 地圖標(biāo)注制作道路 珠海銷售外呼系統(tǒng)運(yùn)營(yíng)商 外呼系統(tǒng)啥意思 地圖標(biāo)注創(chuàng)業(yè)項(xiàng)目入駐 廣州三五防封電銷卡 電銷外呼系統(tǒng) 排行榜 四川電信外呼系統(tǒng)靠譜嗎
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;
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)頁(yè)搜索結(jié)果中實(shí)現(xiàn)選中一行使其高亮
  • jsp搜索引擎
  • php+ajax做仿百度搜索下拉自動(dòng)提示框(有實(shí)例)
  • asp+ajax仿google搜索提示效果代碼
  • jquery創(chuàng)建一個(gè)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í)時(shí)輸入自動(dòng)搜索匹配的方法
  • ajax Suggest類似google的搜索提示效果
  • Ajax+Servlet+jsp顯示搜索效果

標(biāo)簽:紹興 潮州 玉樹 保定 肇慶 廣元 吳忠 北海

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《jsp源碼實(shí)例4(搜索引擎)》,本文關(guān)鍵詞  jsp,源碼,實(shí)例,搜索引擎,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《jsp源碼實(shí)例4(搜索引擎)》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于jsp源碼實(shí)例4(搜索引擎)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    全椒县| 丘北县| 澄迈县| 玛沁县| 道真| 凌海市| 鄂伦春自治旗| 阿拉尔市| 卢氏县| 和林格尔县| 北宁市| 子长县| 耒阳市| 龙江县| 拉萨市| 三门县| 富源县| 陆丰市| 紫阳县| 乐业县| 云林县| 山西省| 扎赉特旗| 东宁县| 宁津县| 乐陵市| 阳新县| 株洲县| 连云港市| 崇仁县| 西青区| 华池县| 大悟县| 榆树市| 龙门县| 屏南县| 堆龙德庆县| 璧山县| 富民县| 周至县| 临猗县|