Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet JSP search engine
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


vasu
JSP search engine
1 Answer(s)      5 years and 4 months ago
Posted in : JSP-Servlet



Advertisement
View Answers

April 7, 2012 at 7:43 AM


1)search.jsp:

<html>
<head>
</head>
<body>
<br><br><br><br><br><br>
<form method="post" name="frm" action="..//search">
<table border="0" width="300" align="center" bgcolor="#CDFFFF">
<tr><td colspan=2 style="font-size:12pt;color:#00000;" align="center">
<h3>Search Item</h3></td></tr>
<tr><td ><b>Item Starts With</b></td>
<td>: <input type="text" name="name" id="name">
</td></tr>
<tr><td colspan=2 align="center">
<input type="submit" name="submit" value="Search"></td></tr>
</table>
</form>
</body>
</html>

2) Search.java:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.sql.*;
import java.sql.*;
import java.util.*;

public class Search extends HttpServlet{

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();

System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";;
String dbName = "register";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";


Statement st;
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
System.out.println("Connected to the database");
String name = request.getParameter("name");
String query = "select * from item where name LIKE '"+name+"%'";
st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
out.println("<table border='1'><tr><th>Row Num</th><th>Item Code</th><th>Item Name</th><th>Item Price</th></tr>");
while(rs.next()){

out.println("<tr><td>"+rs.getString(1)+"</td><td>"+rs.getString(2)+"</td><td>"+rs.getString(3)+"</td><td>"+rs.getString(4)+"</td></tr>");
}
out.println("</table>");
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
}
}

3)web.xml:

<servlet-name>searchServlet</servlet-name>
<servlet-class>Search</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>searchServlet</servlet-name>
<url-pattern>/search</url-pattern>
</servlet-mapping>


Related Tutorials/Questions & Answers:
JSP search engine - JSP-Servlet
JSP search engine  Hi! In my project i have a concept of search engine which has to search in google and display the results in my page. My PM told me use GOOGLE API for search engine. I am developing applicatin in JSP. Can
Search Engine
Search Engine  I have gone through the below mentioned link document to create search engine and fetch the data from mysql database.But i am getting errors. http://www.roseindia.net/sql/mysql-table/sql-search.shtml Error: Notice
Advertisements
Search Engine - Java Beginners
Search Engine  Hello Sir, I am new jsp, also i need search engine coding from the local computer or database only.pls send the jsp with mysql codes.I dont know how to create a search engine(like google) in local computer
Search engine for email
Search engine for email  Build a search engine which will look at your email inbox and sort your email into 5 or more bins according to some criteria (e.g. date, email address, text of the email
simple java search engine
. ABSTRACT Title : Simple Search Engine System Specification: The system on which.... This is needed for every one. The project is simple search engine, which searches...simple java search engine  i have already downloaded the project
Finding searching phrase of a search engine
Finding searching phrase of a search engine  how to find out searching phrase of a search engine..? like, if visitors enter the keyword to google, is is any possible to get that keyword
Search Engine Interface
Search Engine Interface       In this section we will describe about the search and index interface of our search engine. For searching and displaying the result we
Developing Search Engine in Java
Developing Search Engine in Java       In this section we will discuss about the search engine, and then show you how you can develop your own search engine for your website
search engine build by lucene and eclipse
search engine build by lucene and eclipse  Hi, here is the code...); frame.setTitle("SEARCH ENGINE"); frame.setSize(500, 400); frame...()); btnsrc = new JButton("Search"); label = new JLabel("Query
Submitting Web site to search engine
to the search engines, the search engine crawls will visit your site and will index your pages to the search engine index. Once your web site appears... their search engine placement. How to submit the web site to Major
SEO and Search Engines,Best Search Engines on Web,What is Search Engine
SEO and Search Engine   ... of the search engine while doing SEO work. Since in SEO we are using search engine to promote our website, so understanding the search engine details like
Java Search Engine - Java Beginners
Java Search Engine  Hello Sir,The Code Provided by u is very Useful for me,Thank u for Help, but I have one Question is How to Install and Run Mysql ,can I use Sql Server insted of MySql. and How to Install Servlet and Run
save links clicked in search engine results
save links clicked in search engine results  hello i need to access search engine results in my program(any search engine).ie suppose i give a keyword,i need the results returned by that search engine.from the returned results
Writing to be located through the Search Engine
Writing to be located through the Search Engine       The majority of web users depend upon search... a search he should immediately know how the page that has opened up connects to his
Writing to be located through the Search Engine
Writing to be located through the Search Engine  ... search engines of all kind to locate and navigate web pages. While writing text... a search he should immediately know how the page that has opened up connects
Download Search Engine Code its free and Search engine is developed in Servlets
web server. To test your search engine key http://localhost:serverport/servlet/search in your browser. By now your search engine should work.   Download Search
regarding designing of web search engine - Development process
regarding designing of web search engine  we want to design a web search engine in java. so, how to get started with our coding...can i get sample code for web crawlers or similar requirements... help us
How to code a Product id search engine?
How to code a Product id search engine?  I always wonder how people... a search box that let users search products with id. Suppose, "If an user enters id:1234 (and hits search button) go to product page url: http://#" if user
Building Search Engine Applications Using Servlets !
Building Search Engine Applications Using Servlets Introduction This tutorial takes you through the process of building search engine... these days. This search engine shows you how to use Java Servlets
SEO Guide,Search Engine Optimization,Basic of SEO,Search Engine Optimization Information
Search Engine Optimization What is Search Engine Optimization? Search... ranking within search engines. Search Engine Optimization are done to attend the highest ranking in the search engine results for some targeted keywords
Top 10 SEO Mistakes,Common Mistakes in Search Engine Optimization,Search Engine Marketing Mistakes
Search Engine Mistakes - Search Engine Optimization Mistakes... content but they do not rank well on the search engine results. These low placements.... People uses the different Search Engine Optimization techniques to boost web
Welcome to Free search engine secrets: webmaster's guide to search engine registration!
engines, so each search engine submission is your most cost effective form... their search engine placement.      If you... and experience the Search Engine World.    Here I am assuming
Source Code for Search Engine Project in java - Java Beginners
Source Code for Search Engine Project in java  Hello Sir ,I want Java Project for Search Engine(like google),How I can Make it,Plz Give Me Complete Source Code Of Search Engine Project in Java.  Hi Friend, Please
What is SEO,What is Search Engine Optimization,Definition of SEO
; In this article you learn about SEO (Search Engine Optimization) and basics behind the Search Engine Optimization. These days search engine optimization... Engine Optimization? Search Engine Optimization or SEO for short is modification
SEO Tutorials,What is SEO,Search Engine Optimization Tutorial,Definition of SEO
SEO - Search Engine Optimization Here you will find many SEO (Search Engine... breaking any Search engine rules. It is important that you should always use... and useful contents.   What is SEO - Search Engine
Lucene Search in JSP - JSP-Servlet
Lucene Search in JSP  Hello Sir, I want to Develop lucene - Search engine in Jsp page which can Search full text from XML file..through XML parser.. Example: in Search interface there are one textbox after putting some value
Why SEO,Why SEO is Important,Importance of Search Engine Optimization
Why SEO - Search Engine Optimization       In this article I will explain why SEO (Search Engine Optimization... Engine Optimization, Search Engine Submission and Website Promotion is important
Search operation in JSP page
Search operation in JSP page  How to perform search in jsp with MYSQL database plz help me
Search Page in jsp
Search Page in jsp  search page in jsp   Please go through the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
Search page form in jsp
Search page form in jsp  search form in jsp   Please go through the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
search form in jsp
search form in jsp  search page in jsp   Please go through the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
Advertisements
 

 

 

DMCA.com