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



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

Have Programming Question? Ask it here!
 
 
 


premika
Help for Check availability of user
1 Answer(s)      3 years and 7 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
check
updated"); will the above code check if the user has entered value for empcode
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
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
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
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
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
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
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
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   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
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 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
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
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<
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
How to check a checkbox - Struts
How to check a checkbox  Hello Community, How can i check a checkbox defined with tags. with plain html, the tag checks the box. with the other... please help me with the syntax??  Hi friend, my checkbox
help!!!!!!!!!!!!!!!!!!
help!!!!!!!!!!!!!!!!!!  import java.awt.; import java.sql.*; import javax.swing.*; import java.awt.event.* public class NewJFrame extends javax.swing.JFrame { JTextField1
click on check box
click on check box  I create a check box in HTML and when i click on my check box relative information in page store in database
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
check if a substring exists in a string
check if a substring exists in a string  Please I jave an arraylist composed as follwoing [w1, w2, w3, w4, w1.w2.w3, w2.w3.w4, w3.w4, w2.w4, w1.w3... your help. Thanks a lot
how to insert check box
how to insert check box   how to insert check box into jtable row in swing
check box left justification
check box left justification  how to make a check box left justification which is at right end? thanks in advance
To check a palindrome number?
To check a palindrome number?  program to check a number is palindrome or not using recursion?(wihout converting to string
Dynamic check box problem
check boxes ... pleas help me as soon as possible...   1)application.jsp...Dynamic check box problem  In my project i have used a dynamic table, in the each row of that table there is one check box [that i have created
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
What is CHECK Constraint?
What is CHECK Constraint?  What is CHECK Constraint?   Hi, The CHECK constraint is used to limit the value range that can be placed in a column.The SQL CHECK constraint ensures that all values in a column satisfy
check null exception java
check null exception java  check null exception java - How to check the null exception on Java?   The null pointer exception in java occurs... this error. The only way to handle this error is validation. You need to check
check box condition
check box condition  Hai, my application has two check box one for chart and another one for table.when We click chart check box download only... in my application..please help me
check condition in if-else block
check condition in if-else block  Hi, I want to update database with following query int i= st.executeUpdate("Insert into text_editor(words) values('"+words+"')"); how can I give a check option so only valid words are inserted
Hi Check this.... - Java Beginners
Hi Check this....  Hi Sakthi here.. Run This Code..   Hi sakthi Your code is not visible here, can u send again please.. Thanks
Check even or odd number.
Check even or odd number.  How to check given number is even or odd?   Simple if it is devided by 2 it is even and if not if is Odd   import java.io.BufferedReader; import java.io.IOException; import
CHECK THIZ.... - Java Beginners
CHECK THIZ....  Hi friend... import java.io.*; class Plus { public static void main(String args[]) { int a=10; int b= 25; System.out.println("A = " + a + " B = " + b
user in mysql
user in mysql  how to create user in mysql?   Please visit the following link: http://www.roseindia.net/mysql/mysql5/mysql-creating-account.shtml
check youtube iframe code
check youtube iframe code  I have a piece of code that checks the youtube embed code in this format: My PHP code looks like this now: //Check Embed Code $embedCode = $postData['embedCode
 

 

 

DMCA.com