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



Home Answers Viewqa JSP-Servlet Autocomplete textbox with database in jsp and follow the MVC model
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Patel Dolar M.
Autocomplete textbox with database in jsp and follow the MVC model
2 Answer(s)      2 years and 3 months ago
Posted in : JSP-Servlet


i have one problem in my project i try to generate the autocomplete textbox with database mysql follow MVC Model but it not perform. So please Help me sir...

Thanks in advance


Advertisement
View Answers

September 4, 2012 at 4:32 PM


Here is a jsp code that shows autocomplete box using ajax.

1)auto.jsp:

<%@page import="java.sql.*"%>
 <html>
 <head>  
 <script language="javascript" type="text/javascript">  
 var xmlHttp  
 var xmlHttp
 function showState(str){ 
if (typeof XMLHttpRequest != "undefined"){
   xmlHttp= new XMLHttpRequest();
       }
       else if (window.ActiveXObject){
   xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
       }
if (xmlHttp==null){
    alert ("Browser does not support XMLHTTP Request")
return
} 
var url="get.jsp";
url += "?count=" +str;
xmlHttp.onreadystatechange = stateChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
 function stateChange(){   
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){   
 document.getElementById("country").innerHTML=xmlHttp.responseText;  
 }   
 }   
 </script>  
 </head>  
 <body>  
 <input id="name" type="text" name="name" onkeyup="showState(this.value)">
 <br>  
 <div id='country'>  
 </div>  
 </body> 
 </html>

2)get.jsp:

<%@page language="java" import ="java.sql.*" %>  
 <%  
 String name=request.getParameter("count");  
 String buffer="<div>";  
 Class.forName("com.mysql.jdbc.Driver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
 Statement stmt = con.createStatement();  
 ResultSet rs = stmt.executeQuery("Select * from country where countryname LIKE '"+name+"%'");  
   while(rs.next()){

buffer=buffer+rs.getString(2)+"
";
}
buffer=buffer+"

";
response.getWriter().println(buffer);
%>

For more information, visit the following link:

http://www.roseindia.net/tutorial/jquery/autoSuggestTextbox.html



September 4, 2012 at 4:35 PM




Related Tutorials/Questions & Answers:
Autocomplete textbox with database in jsp and follow the MVC model
Autocomplete textbox with database in jsp and follow the MVC model  i have one problem in my project i try to generate the autocomplete textbox with database mysql follow MVC Model but it not perform. So please Help me sir
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database.  Hii Sir, Lots of thnx to ur reply .I went through both... of selecting value from autocomplete textbox using jquery in jsp from mysql database
Advertisements
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database.  Sir, Lots of thnx to ur reply .I went through both the tutorials... autocomplete textbox using jquery in jsp from mysql database. Kindly send me
Selecting value from autocomplete textbox using jquery in jsp
Selecting value from autocomplete textbox using jquery in jsp   hello Sir, I completed ur tutorial on autocompletion textbox from database using Jquery in jsp .It worked Fine .Thank you For Ur valuable Guidance .But it does
How to show autocomplete textbox values on combo box option selection using database?
How to show autocomplete textbox values on combo box option selection using database?  When I select option(i.e First Year) then it will show list of student names in auto-complete text box
How to show data from database in textbox in jsp
How to show data from database in textbox in jsp   How to show data from database in textbox in jsp   Here is an example that retrieve the particular record from the database and display it in textbox using JSP. <
By dropdownlist retrive data from database and show in textbox in jsp.
By dropdownlist retrive data from database and show in textbox in jsp.  Hello Sir, I am doing project in jsp.I have to retrive data from database, when I select value from dropdownlist, and that data I want to show in textbox
autocomplete
autocomplete  I used autocomplete from roseindida.net.. i am getting the autocomplete is coming the retrieved values of database in the list..but when i select the value it is not displaying on the field.. and again i need
showing the information of database in textbox
showing the information of database in textbox  how to make a information of a database make appear to the user in the textbox
retrieving data from database to the textbox depending upon the id in jsp
retrieving data from database to the textbox depending upon the id in jsp  Hi, our project involves fetching of data from database into textbox depending upon another textbox value which is productid.First the id entered by us
role of JSP in MVC
role of JSP in MVC  What is the role of JSP in MVC Model?   JSP is mostly used to develop the user interface, It plays are role of View in the MVC Model
JSP Architecture, JSP Model 1 architecture, JSP Model 2 architecture
The JSP Model 2 architecture is based on the popular MVC architecture. Here Model... is the diagram of JSP Model 2 architecture: The MVC architecture is very... architectures. So, in JSP there are two types of architecture of the JSP: Model 1
how can i prevent duplicate records using servlets and MVC model?
how can i prevent duplicate records using servlets and MVC model?  hai, I need a program to insert values into database at the same time it shows... want this program in MVC model.can anyone help me... Thanks&Regards P.Divya
save multiple records into database using jsp/servlet mvc
save multiple records into database using jsp/servlet mvc  hai, this is my jsp where i have enter multiple username and password and save it to database in single hit user.jsp <form action="UserServlet" method="post
display data from database in textbox when id entered in textbox
display data from database in textbox when id entered in textbox  i wanted to enter data in textbox .depending on entered data in textbox data from database should be displayed dynamically in textbox
Upload Image and save in database using jsp-servlet mvc
Upload Image and save in database using jsp-servlet mvc  Here is my code.. In jsp ... <form name=frm method="post" action="Device"> <table> <tr><TD ><B>Upload Image</B><
Upload Image and save in database using jsp-servlet mvc
Upload Image and save in database using jsp-servlet mvc  Here is my code.. In jsp ... <form name=frm method="post" action="Device"> <table> <tr><TD ><B>Upload Image</B><
Dynamically Update textbox from database
Dynamically Update textbox from database  I have a database as shown below.(database created using SQL Server 2005) name : george,simon address... with two text boxes. if I type something in one textbox, the corresponding value
autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me
autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me   Hi have develop the jsp to populate...;jQuery UI Autocomplete - Multiple, remote</title> <link rel="stylesheet
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file
Solution field from database and display in the textbox of the jsp.   1... in textbox values in jsp file  Hi am new to java. i need to create... a jsp file which contains a textbox, name issuedescription. when user types
Getting Textbox data from database
Getting Textbox data from database  When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown...; org.apache.jasper.JasperException: Exception in JSP: /raisereq.jsp:72 <tr> <td width="108
Getting Textbox data from database
Getting Textbox data from database  When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown...;Here is a jsp code that retrieves data from database and display
javascript for textbox - JSP-Servlet
javascript for textbox  Dear sir , How to write a javascript for a textbox ?.I am doing a delet operation.When i clik on a particular record...:8080/examples/jsp/deleteuser.jsp?id='+id,'mywindow','width=500, height=350,toolbar
Selecting a radio button in jquery autocomplete from database value
Selecting a radio button in jquery autocomplete from database value  I can get the data from the database using PDO to my jquery.js file. How do I... radio button? Here is the pertinent code: $("#name").autocomplete
store dynamic generated textbox value into database
store dynamic generated textbox value into database  sir, how do i store dynamically generated textbox value into the database thanks in advance
javascript for textbox - JSP-Servlet
('http://localhost:8080/examples/jsp/deleteuser.jsp?id='+id+'&&reas='+reason
Jsp using mvc - JSP-Servlet
Jsp using mvc  hi I have written using mvc2 architecture, i have... for that.  Hi friend, 1). Model: The model object knows about all the data that need to be displayed. It is model who is aware about all the operations
How to insert dynamic textbox values into database using Java?
How to insert dynamic textbox values into database using Java?  Hi I am trying to insert dynamic textbox values to database, my jsp form have 2... these dynamic textbox values to database(Oracle 11g)...Please help me out. I have
mvc
mvc  I want MVC example using jsp,servlets,pojoclass,jdbc(with mysql... in "Model view controller" format. last time i asked the same question, but i get only jsp servlets web application from your website & some other links. so
Model View Architecture - JSP-Interview Questions
Model View Architecture  Describe the architectural overview of Model view architecture?  Hi friend, Model-view-controller (MVC... of the application or the underlying business rules without affecting the other. In MVC
populating textbox value from the database using onchange function,
populating textbox value from the database using onchange function,  hi, Everyone I have a problem regarding poulatinng the value in textbox after.... but the next textbox value is populated from database. plz help me guys
Advertisements
 

 

 

DMCA.com