
code for how to search contacts in mobile phone using servlet and jsp??for e.g. when we click on letter a the all contacts starting with a should be displayed.....

Here is a simple jsp code that displays the contact numbers started with the given number.
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("div").innerHTML=xmlHttp.responseText;
}
}
</script>
</head>
<body>
<input id="name" type="text" name="name" onkeyup="showState(this.value)">
<br>
<div id='div'>
</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 person where contactNo LIKE '"+name+"%'");
while(rs.next()){
buffer=buffer+rs.getString("contactNo")+"<br>";
}
buffer=buffer+"</div>";
response.getWriter().println(buffer);
%>
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.