search
HomeDatabaseMysql Tutorialjsp源码实例4(搜索引擎)_MySQL

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; 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,
"

" + message + "

");

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
如何在 iPhone 和 iPad 上更改搜索引擎如何在 iPhone 和 iPad 上更改搜索引擎Apr 25, 2023 am 08:28 AM

在iPhone或iPad上的Safari、GoogleChrome或其他浏览器中更改搜索引擎非常简单。本教程将向您展示如何在iPhone和iPad上可用的四种不同网络浏览器上进行操作。如何更改iPhone或iPad上的Safari搜索引擎Safari是iOS和iPadOS上的默认网络浏览器,但您可能不喜欢这个搜索引擎。幸运的是,您可以使用以下步骤进行更改:在iPhone或iPad上,从主屏幕启动设置。向下滑动并从列表中点按Safari。在下一个菜单中,

Java开发:如何实现搜索引擎和全文检索功能Java开发:如何实现搜索引擎和全文检索功能Sep 21, 2023 pm 01:10 PM

Java开发:如何实现搜索引擎和全文检索功能,需要具体代码示例搜索引擎和全文检索是现代互联网时代的重要功能。它们不仅可以帮助用户快速找到想要的内容,还可以为网站和应用程序提供更好的用户体验。本文将介绍如何使用Java开发搜索引擎和全文检索功能,并提供一些具体的代码示例。使用Lucene库实现全文检索Lucene是一款开源的全文检索引擎库,由ApacheSo

人工智能搜索领域,谷歌微软展开对抗人工智能搜索领域,谷歌微软展开对抗Apr 08, 2023 am 11:31 AM

自去年年底推出以来,ChatGPT被看作对传统搜索信息方式的重大威胁。因为它是多样化的,可以回答人们的问题,编写论文或诗歌,甚至编写程序代码。对话式人工智能提供连贯答案的能力被认为是对谷歌搜索引擎的威胁,几十年来,谷歌一直是人们在互联网上搜索信息的标杆平台。OpenAI的ChatGPT可以定制用户提出的特定问题的答案,这可以节省浏览网站的时间。《纽约时报》12月发布的一份报告显示,ChatGPT一夜之间的成功迫使谷歌称其为“红色代码”,并开始应对人工智能聊天机器人对其搜索引擎业务造成的威胁。根据

PHP搜索引擎性能优化:Algolia的妙用之道PHP搜索引擎性能优化:Algolia的妙用之道Jul 23, 2023 pm 04:21 PM

PHP搜索引擎性能优化:Algolia的妙用之道随着互联网的发展和用户对搜索体验的要求不断提高,搜索引擎的性能优化变得至关重要。在PHP开发领域,Algolia是一个强大且易于集成的搜索引擎服务。本文将介绍Algolia的妙用之道以及如何通过Algolia来优化PHP搜索引擎的性能。Algolia介绍Algolia是一家基于SaaS模式的搜索引擎服务提供商,

PHP和Manticore Search开发:打造高效的搜索引擎PHP和Manticore Search开发:打造高效的搜索引擎Aug 07, 2023 am 09:45 AM

PHP和ManticoreSearch开发:打造高效的搜索引擎搜索引擎在现代互联网应用中起着非常重要的作用。为了实现高效和准确的搜索功能,我们需要选择合适的搜索引擎,并使用适当的开发工具进行开发。本文将介绍如何使用PHP和ManticoreSearch开发一个高效的搜索引擎。ManticoreSearch是一个强大的开源搜索引擎,它基于SphinxS

使用PHP和Elasticsearch构建高效的搜索引擎使用PHP和Elasticsearch构建高效的搜索引擎Jul 09, 2023 pm 04:57 PM

使用PHP和Elasticsearch构建高效的搜索引擎引言:在当今互联网时代,搜索引擎是人们获取信息的首选工具。为了提供快速准确的搜索结果,开发人员需要构建高效的搜索引擎。本文将介绍如何使用PHP和Elasticsearch构建高效的搜索引擎,并给出相应的代码示例。一、什么是Elasticsearch?Elasticsearch是一个分布式的开源搜索和分析

如何在PHP7.0中实现一个全文搜索引擎?如何在PHP7.0中实现一个全文搜索引擎?May 26, 2023 pm 04:51 PM

随着信息时代的不断发展,人们越来越依赖互联网来获取信息。而作为信息分享的平台之一,网页搜索引擎也在不断进化和完善。本文将介绍如何在PHP7.0中实现一个全文搜索引擎,帮助读者更好地利用PHP技术,快速构建高效率的搜索引擎。一、全文搜索引擎概述全文搜索即使用关键词或短语在整篇文档中进行搜索,以找到最匹配的结果。全文搜索引擎使用算法对文档进行索引,以加速搜索。在

构建强大的搜索引擎:PHP与Algolia的结合实践构建强大的搜索引擎:PHP与Algolia的结合实践Jul 22, 2023 pm 01:30 PM

构建强大的搜索引擎:PHP与Algolia的结合实践搜索引擎在当今互联网时代扮演着至关重要的角色,为用户提供快速、准确的搜索结果。而在实现强大的搜索功能时,PHP作为一种常用的编程语言,结合Algolia这个高性能的搜索服务,可以为网站或应用程序提供出色的搜索体验。本文将介绍如何使用PHP和Algolia构建强大的搜索引擎,并附上一些代码示例供读者参考。一、

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment