Help for Check availability of user

Help for Check availability of user

I need the code for check availability of users in the database before login.I placed a button for Check Availability.Can it be done with this or ajax should be used?

View Answers

February 14, 2011 at 12:11 PM

JSP Check availability of User using Ajax

1)availability.jsp:

<html>
<head>
<script type="text/javascript">
function check(value){ 
xmlHttp=GetXmlHttpObject()
var url="checkajax.jsp";
url=url+"?name="+value;
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged(){ 
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
    var showdata = xmlHttp.responseText; 
    document.getElementById("mydiv").innerHTML= showdata;
    } 
}
function GetXmlHttpObject(){
var xmlHttp=null;
try{
  xmlHttp=new XMLHttpRequest();
 }
catch (e) {
 try {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e){
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
</script>
</head>
<body>
<form name="form">
 UserName: <input  type="text" name="name" id="name" onkeyup="check(this.value);"><font color="red"><div id="mydiv"></div></font>
</form>    

</body>
</html>

2)checkajax.jsp:

<%@ page import="java.sql.*" %> 
<%
String name = request.getParameter("name").toString();
System.out.println(name);
String data ="";
try{
           Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from login where username='"+name+"'");
int count=0;
          while(rs.next())
          {

                   count++;
          }

                    if(count>0)
          {
             data="Not Available";
          }
          else
          {
                      data="Available";
          }
out.println(data);
System.out.println(data);
}
catch (Exception e) {
System.out.println(e);
}
%>

Thanks

Ads









Related Tutorials/Questions & Answers:
Help for Check availability of user
Help for Check availability of user  I need the code for check availability of users in the database before login.I placed a button for Check Availability.Can it be done with this or ajax should be used
ModuleNotFoundError: No module named 'check-availability'
ModuleNotFoundError: No module named 'check-availability'  Hi, My... named 'check-availability' How to remove the ModuleNotFoundError: No module named 'check-availability' error? Thanks   Hi, In your
Advertisements
check username availability using JSP & JQuery
check username availability using JSP & JQuery  Hi sir I want check username availability using JSP & JQuery. Please add code with your answer. Thnks in advance
XP Bowling Game User input help
XP Bowling Game User input help  I was asked to do the XP Bowling... to make the code accept input from a user and display the scores/frames... but with no fruitful results. Any help
check
updated"); will the above code check if the user has entered value for empcode
help
program to check all above mentioned methods by invoking it. It should display.... Problem: ? Modify the project to create user interface. Your program should let the user to enter information of your project from a text field and should
help
help  pls help me to get the code of a java program a program to perform different shapes in a menu using javaapplet
help
help  i need help with this code. write a java code for a method named addSevenToKthElement that takes an integer array, and an integer k as its arguments and returns the kth element plus 7. any help would be greatly
need help with two dimensional array that takes input from user and bubble sorts and selections sorts
need help with two dimensional array that takes input from user and bubble sorts and selections sorts  I can get both of the sorts figured out but i... how many elements are going to be input by the user?   Here is a code
HELP
HELP  I need this code to open in a new web browser. but no matter what i do it wont please help?? Directive 055 Storage Requirements for the Upstream Petroleum Industry
Help...
Help...  Write a class that displays your first name vertically down the screen ?? where each letter uses up to 5 rows by 5 columns of a character input by you with a blank line between each letter
Help
Help   i have a html file.. i have take input and store in database .. Tell me the steps to perform.. i have xampp it includes mysql,tomacat,apache. and how display the data from datbase .. please explain
Help!
Help!  thanks for ur code, I'd like to ask a question: after press "c" or "C", timer starts and after every delay ms, it'll print "This line is printed only once." or just print once. I'm writting a timer but it seems to perform
help
help  write an application that prints every integer value from 1 to the number specified by the user along with the squared value of each integer.   Hi Friend, Try this: <html> <h3>Sqaure of Numbers<
Adv. Help! Console messenger. How to anticipate if the user is writing something or just waiting for messages
Console messenger. How to anticipate if the user is writing something or just... it as soon as receives it. The question is how to know that the user is typing a message or not because if the user is typing a message, the recieved message
Search an elements in the array
: In the above program user check the availability of the element in the array. When... to check the availability of an element in the array. Array is a collection of similar data type used in most of the programming languages. By the help
help!!!!!!!!!!!!!!!!!!
help!!!!!!!!!!!!!!!!!!  import java.awt.; import java.sql.*; import javax.swing.*; import java.awt.event.* public class NewJFrame extends javax.swing.JFrame { JTextField1
Help
Help  write a program that reads an integer and check whether it is even. for example, if your input is 25, the should be: is 25 an even number? false if your input is 2000, the should be: is 2000 an even number?true
help
in the printf method is actually invalid.Therefore error occurs. Anyways, check your code
ModuleNotFoundError: No module named 'django-mp-availability'
ModuleNotFoundError: No module named 'django-mp-availability'  Hi...: No module named 'django-mp-availability' How to remove the ModuleNotFoundError: No module named 'django-mp-availability' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-mp-availability'
ModuleNotFoundError: No module named 'django-mp-availability'  Hi...: No module named 'django-mp-availability' How to remove the ModuleNotFoundError: No module named 'django-mp-availability' error? Thanks   Hi
user registration
user registration  hi frnds...am working on a project in JSP.i want to create a user registration form with username,password,mail id and check box... it in Ms Access database for admin purpose.pls help me with this coding guys
help pleas? -_-
help pleas? -_-  Write a Java program that reads from the user an integer N followed by N integers. The program then prints the product of odd integers, and, the sum of even integers
Help with this program
Help with this program  Write a program that would do the following: 1) Read two Strings from the user 2) The user should input two integer numbers... a user inputs doubles
Regular Expression Help Help HELP!!!!
Regular Expression Help Help HELP!!!!  HI all I am very new to java... could help me to give a solution of how to retrieve the name and email add... the quotes ""07001", "MR Harish Ram","M.RHarish @ hotmail.com"" Help is greatly
Help with this program
Help with this program  Write a program that would do the following: 1) Read a String from the user. The String will be the following: "My grade is x" (where x is an integer between 0-9) 2) Get the String to integer by creating
ModuleNotFoundError: No module named 'odoo10-addon-stock-ownership-availability-rules'
ModuleNotFoundError: No module named 'odoo10-addon-stock-ownership-availability...: ModuleNotFoundError: No module named 'odoo10-addon-stock-ownership-availability...;odoo10-addon-stock-ownership-availability-rules' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo8-addon-mrp-disable-force-availability-button'
-availability-button'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo8-addon-mrp-disable-force-availability...;odoo8-addon-mrp-disable-force-availability-button' error? Thanks   
ModuleNotFoundError: No module named 'odoo8-addon-stock-ownership-availability-rules'
ModuleNotFoundError: No module named 'odoo8-addon-stock-ownership-availability...: ModuleNotFoundError: No module named 'odoo8-addon-stock-ownership-availability...-stock-ownership-availability-rules' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo10-addon-stock-disable-force-availability-button'
-availability-button'  Hi, My Python program is throwing following error...-availability-button' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-stock-disable-force-availability-button' error? Thanks
ModuleNotFoundError: No module named 'odoo10-addon-stock-ownership-availability-rules'
ModuleNotFoundError: No module named 'odoo10-addon-stock-ownership-availability...: ModuleNotFoundError: No module named 'odoo10-addon-stock-ownership-availability...;odoo10-addon-stock-ownership-availability-rules' error? Thanks   Hi

Ads