Home Answers Viewqa JSP-Interview-Questions 6769-Source-Code-for-Implementing-Search-Feature-in-JSP-using-Java-Action Source Code for Implementing Search Feature in JSP using Java Action/Servlet

 
 


Laksmi Chandra
Source Code for Implementing Search Feature in JSP using Java Action/Servlet
2 Answer(s)      3 years and 9 months ago
Posted in : JSP-Interview Questions

View Answers

August 12, 2009 at 4:20 PM


Hi Friend,

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>

Thanks

August 13, 2009 at 8:22 AM


I have following your source code, but I get this error:

HTTP Status 405 - HTTP method GET is not supported by this URL

type Status report

message HTTP method GET is not supported by this URL

description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).
Apache Tomcat/6.0.18

I don't know my fault??? Would you mind helping me....


Thanks for all









Related Pages:
Source Code for Implementing Search Feature in JSP using Java action/Servlet - JSP-Servlet
Source Code for Implementing Search Feature in JSP using Java action/Servlet  How do I write the source code to implement search feature in JSP using Java action/servlet? My query is: SELECT @rownum:=@rownum+1 'rownum', X
Source Code for Implementing Search Feature in JSP using Java Action/Servlet - JSP-Interview Questions
Source Code for Implementing Search Feature in JSP using Java Action/Servlet  How do I write the source code to implement search feature in JSP using Java action/servlet? (java action is the priority, but servlet is OK) My
Source Code for Implementing Search Feature in JSF/JSP using Servlet - Java Beginners
Source Code for Implementing Search Feature in JSF/JSP using Servlet  How do I write the source code to implement search feature in JSF/JSP using Servlet?? Please advice using the example data below:- Thank You!! Employee
B+ tree JAVA source code for implementing Insertion and Deletion - Java Beginners
B+ tree JAVA source code for implementing Insertion and Deletion  Can anyone plz mail de B+ tree JAVA source code for implementing Insertion...("Search value is: " + root.Search(24)); System.out.println("Search value
Implementing a SoftReference based HashMap - Java Tutorial
Implementing a SoftReference based HashMap 2001-03-28 The Java Specialists' Newsletter [Issue 015] - Implementing a SoftReference based HashMap Author... either via email or RSS. Welcome to the 15th issue of "The Java(tm
search feature - JSP-Servlet
search feature  i need help to do a search feature servlet to search for employees from the database. the search will be done by search by employee name, department and email  Hi friend, As per your problem
how to point my jsp form action to servlet? - JSP-Servlet
how to point my jsp form action to servlet?  I am currently using... was trying to point my jsp action to my servlet.(f.action="../fyp.servletLogin";) fyp is the folder that stores my servlet. Here is my function code in jsp, when user
Java Source code
Java Source Code for text chat application using jsp and servlets  Code for text chat application using jsp and servlets
Capturing JSP Content Within My Strut Action Servlet - JSP-Servlet
Capturing JSP Content Within My Strut Action Servlet  My end goal is to be able to grab the content from the JSP from within the calling servlet... see that might be able to help me out? {code} /* ... do stuff in Servlet
Implementing FTP in Java Code
Implementing FTP in Java Code  Hi, My job is to write a program in Java in my project. I have to implement FTP in my Java Code. Share me some of the code of Implementing FTP in Java Code. Thanks   Hi, Apache ftp
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
implementing DAO - Struts
implementing DAO  Hi Java gurus I am pure beginner in java... This tutorial shows, how to create the source code of Dao and DaoImpl class.... Source Code of Dao.java package com.roseindia.portal.dao; import
Auto complete of word search using ajax with java
using jsp to design the form. I want ajax sample to achieve this feature. Its like google search. Please help. Thanks in advance...Auto complete of word search using ajax with java  I want to display
Auto complete of word search using ajax with java
using jsp to design the form. I want ajax sample to achieve this feature. Its like google search. Please help. Thanks in advance...Auto complete of word search using ajax with java  I want to display
implementing an algorithm using multi threads - Java Beginners
implementing an algorithm using multi threads  Hi i need to implement an algorith in multi threads.Algorithm has data dependency so i need to pass... to calculate execurion time.# Here is my code: import java.io.*; class MT
using servlets and jsp technologies search the documents - Development process
using servlets and jsp technologies search the documents   write a program to develop search contents,uploading data and advance searching options using servlets and jsp with source code
Implementing Bean with scriptlet in JSP
; Example for implementing bean with scriptlet <% code %> in a JSP page We can use all of the JSP coding while using Java Beans in a JSP page... example will describe you to use JSP Scriptlet in a JSP page using Java Beans
java source code
java source code  java source code to create mail server using struts2
JSP Search Example code
. We are using MySQL database and JSP & Servlet to create the application. We are using Eclipse IDE to deploy and run the JSP search book example... by ISBN Code or Book Category in a jsp and servlet web application .This 
Sorting data in a jsp using a servlet while implementing comparable - JSP-Servlet
Sorting data in a jsp using a servlet while implementing comparable  ... which is stored in the session scope of a servlet. Below is its code... at line 14 of the jsp code. I also want it to implement comparable to use
request for java source code
request for java source code  I need source code for graphical password using cued-click points enabled with sound signature in java and oracle 9i as soon as possible... Plz send to my mail
how to write a program to search a record using mvc2
how to write a program to search a record using mvc2   how can we write a code to search a record in table by using java bean as model, servlet as contoller and jsp as view
source code of java
source code of java  how to create an application using applets is front end and back end is sqlwith jdbc application is enter the student details and teaching & non teaching staff details and front end is enter in internet
source code - Java Beginners
source code  Hi...i`m new in java..please help me to write... and units in the amounts arrays. (amounts[1]=prices[1]*units[1].output display using message dialog box.  Hi Friend, Try the following code: import
View source code of a html page using java ..
View source code of a html page using java ..  I could find the html source code of a web page using the following program, http://download.oracle.com/javase/1.4.2/docs/api/java/net/URLConnection.html i could get the html code
Building Search Engine Applications Using Servlets !
using Java Servlets. You can Download the source code of search... application. Search Engine Code and Updates The source code...Building Search Engine Applications Using Servlets Introduction
Implementing ArrayList's functionalities into arrays - Java Beginners
Implementing ArrayList's functionalities into arrays  Hi guys, i'm.......ARRAYS! I've already tried to solve it using Arraylists and faced no problems... allows with just a line of code, such as GET, ADD and REMOVE. Any ideas? Thanks
source code - JDBC
source code  give me a source code to connect from java to mysql that can run on eclipsed i am using mysql-essential-5.0.41-win32_1. also give procedure how can i connect from eclipsed to mysql-essential-5.0.41-win32_1. thanks
Implementing Digits restriction Using JQuery
Implementing Digits restriction Using JQuery  Hi Sir I have.... Please provide code.   You can implement these two things using ASCII code & parseint method. Code is provided below : //called when key is pressed
SEARCH PAGE
for this using jsp...?   Please visit the following links: http...SEARCH PAGE  search page:option for search criteria like name and DOB will be asked.on entering the detail,data matching search criteria
SEARCH AND SORT
SEARCH AND SORT  Cam any one provide me the code in java that : Program to search for MAX,MIN and then SORT the set using any of the Divide and conquer method
java source code - Java Beginners
java source code  hello Sir, Im a beginner in java.im greatly confused, so plz send me the source code for the following concept: Telephone... and phone number for N subscribers and perform the following operations : 1. Search
source code program - Java Beginners
source code program  I need the source code for a program that converts temperatures from celsius to fahrenheit and vice versa, as well as converting kilometers to miles and vice versa using Java "classes".  Hi
Implementing voice commands
Implementing voice commands  Am trying to write a java program to implement voice commands within a windows platform using preferably java (though any language will do). I would be glad for any tips and procedures that would help
Need Java Source Code - JDBC
Need Java Source Code  I have a textfield for EmployeeId in which... be implemented.  Hi friend, Please send me code because your posted.... http://www.roseindia.net/jsp/ Thanks
source code in jsp
source code in jsp  i need the source code for online payment in jsp
source code
source code  hellow!i am developing a web portal in which i need to set dialy,weekly,monthly reminers so please give me source code in jsp
java source code to create mail server using struts2
java source code to create mail server using struts2  java source code to create mail server using struts2
Auto Search box using ajax
Auto Search box using ajax   Hi , i want to implement auto search box functionality like google and linkedin using ajax,jsp,servlet, javascript... this is possible in java. rahul   hi, Please go through the link, may
source code in jsp
source code in jsp  how to insert multiple images in jsp page of product catalog
Implementing JSP and embedding Windows Media Player(wmp)
; Example code for implementing JSP and also embedding wmp in JSP page... Implementing JSP and embedding Windows Media Player(wmp... by giving the source path. This will make your JSP page interactive. Before
java source code to send group mails using struts2
java source code to send group mails using struts2  code to send group mails using struts2
source
source  how to pass the morethan one fields from one page to another page in struts1.2? i am using tchnologies are struts1.2 oracle 10g myecllipse 8.6 so please post the exact source code to support the above technologies
source code - JSP-Servlet
source code  i need source code for client server application in jsp to access multiple clients   Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/ Here you will get lot of examples
source code
source code  how to get the fields from one page to another page in struts by using JSTL
Redirect to Google Search JSP
a google search using a JSP page. We will use Eclipse to compile and deploy...Redirect to Google Search JSP This tutorial explains you how can you crate.... To create a Google search on the web page we will use JSP. Example Here we
Implementing Data Access Layer with Hibernate
Implementing Data Access Layer with Hibernate  ... we are using Hibernate to implement data access layer. Hibernate is an open source O/R mapping framework that handles all the persistence logic. Hibernate
JSP code
JSP code  I get an error when i execute the following code : <%@ page language="java" contentType="text/html; charset=ISO-8859-1...) java.lang.Class.forName(Unknown Source) org.apache.jsp.savedetails_jsp
source code - JSP-Servlet
source code for webcam chat application  I want source code for this webcam chat application. I like the concept of XAWARE ORG regarding web cam chat. So that i want the code through this XAWARE only.pls send the code as soon
source code - JSP-Servlet
source code  please i want source code for online examination project (web technologies)  Hi Friend, Send some details of your project. Thanks

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.