Get all updates of Java4s
Follow Us: Email Newsletter

Checking User Name Availability With AJAX – Google Style

Ajax » On Oct 25, 2011 { 35 Comments } By Sivateja

We will see how to check the user name availability in the database with ajax,  this is some thing what we can find out at time of gmail signup

Files Required

  • index.html
  • pass.jsp
  • web.xml

Index.html

pass.jsp

web.xml

OutPut

Note: you must have classes12.jar, ojdbc14.jar in the lib folder of you application

Database

Check Output

Click here to check the output

You Might Also Like

  ♦ About Author ♦

Java4s_Author
sivateja@java4s.com
Full Stack( Java/J2EE & UI/UX ) Developer and founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog. Sign-up for the Email Newsletter for your daily dose of Java tutorials.

Comments

35 Responses to “Checking User Name Availability With AJAX – Google Style”
  1. Sumit Kumar says:

    I tried this project at home but was unable to run. So, can you provide the download link for this project.

    Thanks.

  2. Kavya says:

    Nicely explained.. Thank you

  3. smurfiiee says:

    Thank you!! it work !! (:

  4. Java4s says:

    @Kavya, @smurfiiee

    Thanks for your feedback :-)

    @Sumit Kumar
    We can provide direct download link, if so you can’t get whats going exactly with ajax, just try once from your end slowly.

  5. Raju says:

    sir nice tutorial,but i couldn’t get something in the index.html file var urls=”pass.jsp?ver=”+k; and there is no attribute in in field,how can we use String sn=request.getParameter(“ver”); in pass.jsp.please explain it,thank you.

  6. Java4s says:

    @Raju

    See the flow…

    Once we enter any character at line number 34(index.html), onkeyup we will be moved to line number 4 right,
    the character we entered will be copied to variable k(line number 7), and we formed request url at line number 8 by passing k value(so k value will move along with URL hope you know this).

    In pass.jsp i have retrieved that k value by calling the attribute ‘ver’ because in the url we assigned k value to ‘ver’ variable.

    If you are fresher you may feel little confusion, but its very simple. Read it slowly.

  7. Vijay says:

    instead of using out.println is there any other way to send response from server ?

  8. shaan rizvi says:

    amazing exaple……..thank u..

  9. thanks a lot dude..!!!!nice explained

  10. sefwetet says:

    nice tutorial….thanks a lot

  11. cool thanks sir.. working good

  12. pallavi says:

    Hi Siva,

    Thanks for wonderful answers and articles posted by you ..

    But whenever I am opening this site ..it takes alot of time to load.firstly i thought it would be problem of my browser.But with whatever browser i open this site it is slow.Please could you make changes to this site such that we could be able to access this faster.

    Thanks once again!!!!!!!!!

  13. Nice SIr………..Good Job….Thank yOu

  14. anusha says:

    thank you sir,we need more examples,Please provide

  15. Abhinav says:

    what is the use of ” web.xml ” file?

  16. phphunger says:

    very nice tutorial.the same thing i have implemented in php…

  17. pavan says:

    Nice tutorial. Explanation was clear and simple. Thank you.

  18. Chandan says:

    Can you please show the code of ajax server side validation for checking userid already exists or not….by using struts and hibernate

  19. Fakhrul says:

    Very very nice explain sir thank you so much

  20. mahesh says:

    This code for using mysql database

    String sn = request.getParameter(“ver”);
    Connection connection= null;

    Class.forName(“com.mysql.jdbc.Driver”);
    String url = “jdbc:mysql://localhost:3306/emp”;
    String userName = “root”;
    String password = “”;
    connection = DriverManager.getConnection(url, userName,
    password);

  21. Uday says:

    Thanks siva:)
    with the help of your explanations, I regained the hope to do programming!

  22. Sudhir says:

    What if i wanaa use Servlet instead of jsp?

  23. Mostafijur rahman says:

    thank you soooo much sir..great explanation.its working!! :D :)

  24. mm says:

    its showing message only but its accepting even for already exists name in my program

  25. surendra kumar says:

    it is working fine but it display only first row in result set.how to display all row in database

  26. Mukesh says:

    Beneficial Topic

  27. Subhankar Chowrasia says:

    Thank u for the code..

  28. akhildas says:

    good example excellent

  29. Mohsin says:

    You cant simply call the db from.jsp .This is not a correct approach i guess.

  30. Sivateja says:

    @Mohsin

    You are correct, but I have shown just to make it as a simple example.

  31. yogesh says:

    how to get it from dao without pass.jsp??

  32. Alok gautam says:

    it is not full code..i need to stop submit form..if user already exist…. please provide me

  33. srikanth says:

    SEVERE: Servlet.service() for servlet [jsp] in context with path [/uservalid] threw exception [java.lang.ClassNotFoundException: org.apache.jsp.userValid_jsp] with root cause

    can you tel me?

    why it should occur?

  34. makhna says:

    i have query . you have send the data to server by url like this “pass.jsp?ver=”+k and for that you have used get method .but i want to use post method .and is their any other way of sending ver to the server .please help me it will be really helpfull

  35. Yogesh says:

    Most importantly Your code compile without any error..Thanks For sharing Different modules…

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
What would you like to learn today?
Browse these popular technologies
Hibernate spring struts Servlets ajax Log4j jQuery Json Core Java Web Services AngularJs
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Useful Links Current & UpComing Tutorials
Upcoming
  Web Services [ SOAP ], JSP
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2016 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.