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









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
jQuery check username availability using JSP
jQuery check username availability using JSP In this section, you will learn to check username availability from database using JSP & jQuery...;CheckUsername.jsp",{user: ""+inputString+""},function(data
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
need help for writting code in struts action class for check boxes and radio buttons - Struts
need help for writting code in struts action class for check boxes and radio buttons  Hello frnds, i need help from u esteemed and talented people.iwould like to write code in struts action class for check boxes and radio
help
verification mail to the user) please tell me how could i design that. Please help me... like REGISTER USERNAME (here i have to check whether username already exists in database) EMAIL ADDRESS (here i have to check whether email address already
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
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
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
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
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
help
help   how i can send a pitcture on url in java
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
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  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<
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  Hi; Can anyone help me to solve this errors. I use J2ME(wirlesee Toolkit 2.5.2. for CLDC Project "SlideImageMIDlet" loaded Project settings saved Building "SlideImageMIDlet" C:\Documents and Settings\???? ?????\j2mewtk
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 '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
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-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-disable-force-availability-button'
-availability-button'  Hi, My Python program is throwing following error...-availability-button' How to remove the ModuleNotFoundError: No module named 'odoo8-addon-stock-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 'odoo8-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 'odoo8-addon-stock-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 'odoo9-addon-mrp-disable-force-availability-button'
-availability-button'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'odoo9-addon-mrp-disable-force-availability...;odoo9-addon-mrp-disable-force-availability-button' error? Thanks   
ModuleNotFoundError: No module named 'odoo9-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 'odoo9-addon-stock-disable-force-availability-button' error? Thanks  
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
Struts 2.5.10.1 General Availability - released
Struts 2.5.10.1 General Availability is released with a potential security fix Struts 2.5.x's latest version is released on 7 march 2017 with a security fix... to this version of Struts 2.5x framework. The GA (General Availability) version
How to Check Automorphic Number using Java Program
How to Check Automorphic Number using Java Program Automorphic numbers... of number 6 at the end. Here we are going to check whether the number entered by the user is automorphic or not. Here is the code: import java.math.
User Guide, User Manuals Guides
Tips for Writing User's Manual Guide We are living in an edge of technological... the need of user guides and manuals. To let people know the various features of a product, user guides and manuals are required that deliberates on various
PHP User Defined Function
PHP User Defined Function An user-defined function saves  us from ... smaller. The given examples will help to understand how you can put them to work... functions as per the need. General structure of the user defined function is:ADS
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
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
check for errors
check for errors  How can I check for errors
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. (adsbygoogle = window.adsbygoogle || []).push
password check
password check  how to check sighup passowrd and login password
check anagram
check anagram   compare two input is anagram or not but input contains million words
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
help in java
help in java  Write a program that will evaluate simple expressions such as 17 + 3 and 3.14159 * 4.7. The expressions are to be typed in by the user..., and so on. The program should end when the user enters 0 as the first number

Ads