濮阳杆衣贸易有限公司

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

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

熱門標(biāo)簽:長春回?fù)芡夂粝到y(tǒng)廠家 山東智能云外呼管理系統(tǒng) 地圖標(biāo)注制作道路 珠海銷售外呼系統(tǒng)運(yùn)營商 外呼系統(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)頁搜索結(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)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《jsp源碼實(shí)例4(搜索引擎)》相關(guān)的同類信息!
  • 本頁收集關(guān)于jsp源碼實(shí)例4(搜索引擎)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    特克斯县| 鄂温| 滁州市| 平远县| 新宾| 昂仁县| 惠水县| 若尔盖县| 衡阳市| 湖州市| 荃湾区| 桃园县| 仙桃市| 沙河市| 衡阳市| 永清县| 吉林市| 金溪县| 韶关市| 营山县| 南充市| 海阳市| 当涂县| 神农架林区| 嘉黎县| 阳原县| 石家庄市| 游戏| 自贡市| 囊谦县| 西城区| 定日县| 湘西| 龙山县| 元江| 林州市| 富源县| 乌鲁木齐市| 黄浦区| 永春县| 进贤县|