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



Home Answers Viewqa JSP-Servlet Help for Check availability of user
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


premika
Help for Check availability of user
1 Answer(s)      3 years and 10 months ago
Posted in : JSP-Servlet


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?


Advertisement
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
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
Advertisements
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
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
to the user) please tell me how could i design that. Please help me asap Thanks a lot... 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
check for errors
check for errors  How can I check for errors
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
password check
password check  how to check sighup passowrd and login password
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
check anagram
check anagram   compare two input is anagram or not but input contains million words
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.
Mysql Check
Mysql Check       Mysql Check is used to check the existence of table in the database. Understand with Example The Tutorial illustrate an example from 'Mysql Check
Check Digit Question not able to solve..
Check Digit Question not able to solve..   Hi, I need some help asap. I been stuck for this question for more than 3 days. Using Java. User needs to key in identification number (e.g. U0906931E) system check for the first
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
check box in jsp
check box in jsp  hey guys i am working on a web based project using jsp. In my project 1 am having 9 check boxes in 3 rows in the same form. I want to select 1 check box from each row and also i want to avoid many check box
How to check no records - JSP-Servlet
to check and display your cart is empty.... PLs help me......... Reply...How to check no records  Hi all, I am developing an onlineshopping project, in that how i have 2 check no records. I saw an answer
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
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
To check the Rotational Strings are Equall or not
To check the Rotational Strings are Equall or not  I attended 3dplm... question is................. Write a program to check the given two strings... want o/p true.. please help me
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
HI Jsp check box..!
HI Jsp check box..!  Hi all.. I want to update the multiple values of database table using checkbox..after clicking submit the edited field has to update and rest has to enable to update...please help me..its urgent
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
in the printf method is actually invalid.Therefore error occurs. Anyways, check your code
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!  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<
Advertisements
 

 

 

DMCA.com