Simple Search Engine
<%-- Retrieve and display search results --%>
<%
String query = request.getParameter("query");
if (query != null && !query.isEmpty()) {
// Sample data for demonstration purposes
String[] documents = {
"This is the first document.",
"A simple example for search.",
"Creating a search engine with JavaServer Pages (JSP)."
};
out.println("
Search Results for: " + query + "
"); for (int i = 0; i < documents.length; i++) {
if (documents[i].toLowerCase().contains(query.toLowerCase())) {
out.println("
Document " + (i + 1) + ": " + documents[i] + "
"); }
}
}
%>
0 Comments