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



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

Have Programming Question? Ask it here!
 
 
 


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



Advertisement
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 Tutorials/Questions & Answers:
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
Advertisements
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
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
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 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
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
Java Source code
Java Source Code for text chat application using jsp and servlets  Code for text chat application using jsp and servlets
source code in jsp
source code in jsp  i need the source code for online payment 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
source code in jsp
source code in jsp  how to insert multiple images in jsp page of product catalog
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 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
java source code
java source code  java source code to create mail server using struts2
source code in java for a program using class - Java Beginners
source code in java for a program using class  Dear sir/madam i want source code in java for following program: WAP which creates a class accountthat stores customer name,account number and type of account.From this derive
source code - JSP-Servlet
source code  I want source code for Online shopping Cart... Rakesh, I am sending a link where u will found complete source code..., and Cost. Customers can only view the bill details. Deliverables HTML/ 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
source code in jsp
source code in jsp  sir...i need the code for inserting images into the product catalog page and code to display it to the customers when they login to site..pls help me
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
source code - JSP-Servlet
source code  i want source code for my project online examination it includes two modules user and administrator so if user want to write exam first he register his details and then select the topics on which he want to write
source code - JSP-Servlet
source code  i want source code for my project online examination it includes two modules user and administrator so if user want to write exam first he register his details and then select the topics on which he want to write
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
Java source code
Java source code  How are Java source code files named
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
feature of Java.
feature of Java.  Explain any two feature of Java.   Please visit the following link: Features of Java
Source code of a website in HL and JSP.
Source code of a website in HL and JSP.  I want the source code of a website of 10 pages with database connectivity. Source code should be in HTML and JSP. Thanks
search functionality using jsp from database
search functionality using jsp from database  search functionality using jsp from database
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
code for implementing sale purchase
code for implementing sale purchase  i have two tables in database. in one table i have stock of sms and further details and other table is for customer .if customer purchases my sms then the value will be deduct from my table
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
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
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  What do I have to add to my original code to make it work
Source Code - Java Beginners
Source Code  How to clear screen on command line coding like cls in DOS?  Hi Friend, Here is the code to execute cls command of DOS through the java file but only one restriction is that it will execute
You asked full source code for search - Development process
You asked full source code for search  Hi, For this code can u give me code for display records when i select any field Search Page var arr = new Array(); arr["Select"] = new Array("-select
java source code - Java Beginners
java source code  I have written a source code for recording invoices. I wish it to be evaluated. Could somebody help me with it? Moreover, I do not know the method to attach the JAR for evaluation. My email
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
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
Java Source code - Java Beginners
Java Source code  Write a Multi-user chat server and client
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
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
java source code - Java Beginners
java source code  write a program to read the value of n as total number of friend relatives to whom the person wants to call
Java source code - Java Beginners
Java source code  Write a small record management application for a school. Tasks will be Add Record, Edit Record, Delete Record, List Records. Each Record contains: Name(max 100 char), Age, Notes(No Maximum Limit). No database
java code to search in your hard disck
java code to search in your hard disck  Build a search engine which would scan your hard disk and build an inverted index for your files. The search engine should cluster your files according to some criteria and make some
tree using jsp code
tree using jsp code  i want to draw a tree structure of a family hierarchy using jsp code
i need the source code to generate id in jsp
of generate ids each should have some range...plz give the source code in jsp with ms...i need the source code to generate id in jsp  hai,i need the source code for generate id...which is i need to generate the new id from the maximum
 

 

 

DMCA.com