
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

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+"
For more information, visit the following link:
http://www.roseindia.net/tutorial/jquery/autoSuggestTextbox.html

You can also visit the following link:
http://www.roseindia.net/struts/struts/struts2.2.1/tags/autocompleter_tag.html
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.