Full-text search in JSP

Source: Internet
Author: User

First, let's introduce my news system: the basic information of news stored in the database, such as the title, publisher, release time, and name of the main news file. The news subject is a static page in HTML format (the first is to increase the speed and reduce the pressure on the database. The second problem occurs when the database processes large strings .). The idea of full-text search is: first retrieve all the news from the database, find the news of the subject, and then read the news of the subject into a string through Io operations. Remove unnecessary things, such as HTML tags, and use regular expressions to search for the string. If the matching information is found, record the news. Finally, all qualified news is returned to the user.

The following code is used to enter the query conditions. The query keywords are separated by "+": search. jsp

<HTML>

<Head>

<LINK rel = "stylesheet" href = "CSS/style3.css">

<Title> news search </title>

<Script language = "JavaScript">

Function subform ()

{

If (document. zl_form.keyword.value = "")

{

Alert ("enter a keyword! ");

Document. zl_form.keyword.focus ();

Return false;

}

Return true;

}

</SCRIPT>

</Head>

<Body bgcolor = "# f0f6e2">

<Form name = "zl_form" target = "_ new" method = "Post" Action = "aftsearch. jsp" onsubmit = "Return subform ()">

<Table width = "600" bgcolor = "# f0f6e2">

<Tr>

<TD colspan = "4" Height = "10"> </TD>

</Tr>

<Tr>

<TD width = "14%"> enter the query Keyword: </TD>

& Lt; TD align = "Left" width = "65%" & gt;

<Input size = "50" type = "text" name = "keyword" style = "font-size: 9pt">

<Input type = "Submit" name = "Submit" value = "Search" style = "font-size: 9pt">

</TD>

</Tr>

<Tr>

<TD colspan = "2" Height = "9" align = "Left">

<Br>

<Font color = "red" size = "+ 1"> Note: if multiple query conditions exist, separated by </font> <font size = "+ 2"> + </font> <font color = "red" size = "+ 1">. Example: 1 + 2 + 3 + 4... </font> </TD>

</Tr>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.