Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8678247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:40:04+00:00 2026-06-12T20:40:04+00:00

In my app im using JSP as view,servlet as controller,hibernate as model.. in that

  • 0

In my app im using JSP as view,servlet as controller,hibernate as model..

in that app jsp pages im have to fill form while creating new user with fields like username and all.

now i want to use AJAX code to check if username name with entered name in form is already there in the database or not…

can any1 guide me how to write coding for this as well as the control flow..

i have googled but didnt got any idea how to do this requirement..

thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:40:05+00:00Added an answer on June 12, 2026 at 8:40 pm

    In Jsp

    <script type="text/javascript">
        function VerifyUsername()
        {
            //alert("In Verify Method");
            var name=document.getElementById("username").value;
            //alert(name);
            var xmlhttp;
            if (window.XMLHttpRequest)
            {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp=new XMLHttpRequest();
                //alert("http");
             }
            else
            {// code for IE6, IE5
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                alert("http active");
            }
            xmlhttp.onreadystatechange=function()
            {
                //alert("in Function()");
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {
                    try
                    {
                        //alert("In Try");
                        document.getElementById("errorpass").innerHTML=xmlhttp.responseText;
                        /*var response = xmlhttp.responseText;
                        alert(response);
                        if(response.toString()=='notmatch')
                        {
                            alert("Ok");
                            document.getElementById("errorpass").innerHTML ="OK";
                        }
                        if(response =='match')
                        {
                            alert("Not Ok");
                            document.getElementById("errorpass").innerHTML ="Take Other Name.";
                        }*/
                    }
                    catch(ex)
                    {
                        alert("Exception in function "+ex);
                    }
                }
            }
            //xmlhttp.open("POST","servlet/UsernamePresence_Serv?UserId"+name,true);
            xmlhttp.open("POST","servlet/UsernamePresence_Serv?"+name,true);
            var params = "UserId="+name;
            xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
            xmlhttp.setRequestHeader("Content-length", params.length);
            xmlhttp.setRequestHeader("Connection", "close"); 
            xmlhttp.send(params);
        }
    </script>
    

    in Servlet

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
    
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        try
        {
            Session session=Hibernate_Class.sessionObject();
            String userID=null;
            userID = request.getParameter("UserId");
    
            login_model loginModel_Obj=new login_model();
            loginModel_Obj._Name=userID;
            System.out.print("at "+userID);
            boolean username_bool=Hibernate_Class.usernamePresence(loginModel_Obj, session);
    
            if (username_bool)
            {
                out.println("Username Present In Database");
            }
            else
            {
                out.println("Username Not Present In Database");
            }
    
        }
        finally{}
        out.close();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web app for restaurant order management build using servlet/jsp. I have
I'm creating a Mobile App with JQM and JSP I'm using Bookmark bubble to
I'm using a jsp file as a model from a Controller and I want
greetings all i am using jsp as a view technology in my web app
I am developing a demo app using Servlet/JSP and using logging JAR by apache
I have an application using Java servlets/JSP's. There are multiple clients using my app,
I have a Spring MVC/3.0 app using tiles as it's view, this is working
I'm using the Model/View/Controller style of building web apps by routing an incoming HttpRequest
I have servlet which does a forward using requestdispatcher() to one of my jsp
I am using underscore with backbone in a jsp app. In order to do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.