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 9079909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:56:48+00:00 2026-06-16T19:56:48+00:00

i have somewhat done a ajax based jsp coding for checking username availability. It

  • 0

i have somewhat done a ajax based jsp coding for checking username availability. It worked perfectly. Though it might have some errors. So if there any please point it out. Now my main question is that after the checking i also want generate some usernames for users to use like we can see it at gmail registration form. I am giving my code here…

First the index.html…

    <html>
<body>
<form action=sample.jsp method=post>
id<input type=text name=id><br>
<input type=submit value=next>
</form>
</body>
</html>

Now sample.jsp…

<jsp:useBean id="ob" class="sample.Database" scope="session" />
<jsp:setProperty name="ob" property="*" />
<html>
<head>
var xmlHttp  
    var xmlHttp
    var checkvalue

    function showState(p1){ 
        if (typeof XMLHttpRequest != "undefined"){
            xmlHttp= new XMLHttpRequest();
            }
            else if (window.ActiveXObject){
            xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
            }
        if (xmlHttp==null){
                alert ("Browser does not support XMLHTTP Request")
            return
        } 
        var url="getlist.jsp?name="+p1;
        xmlHttp.onreadystatechange = stateChange;
        xmlHttp.open("GET", url, true);
        xmlHttp.send(null);
    }

    function stateChange(){   
        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){   
            checkvalue=document.getElementById("name").innerHTML=xmlHttp.responseText;
            document.f1.checking.value = xmlHttp.responseText; 
        }   
    }

    function conditions(){
        if(!checkvalue.match("Available"))
        {
            alert("no match");
            return false
        }
    }

</script>  
</head>  
<body >  
<center>
<br>  
<form action="sample1.jsp" name="f1" method="post" onsubmit="return conditions()">
name <input type=text name=name onchange="showState(this.value);"><div id='name'></div><br>
checking<input type=text name=checking><br>
    <input type=submit value=next>



</form>
</body> 
</html>

now getlist.jsp…

    <jsp:useBean id="ob" class="sample.Database" scope="session" />
<%
    String n=request.getParameter("name");
    if(ob.checkName(n)==0)
    {
%>
        <font color=green>Available</font>
<%
    }
    else
    {
%>
        <font color=red>Not available</font>
<%
    }
%>

now sample1.jsp….

<jsp:useBean id="ob" class="sample.Database" scope="session" />
<jsp:setProperty name="ob" property="*" />
<%
    if(ob.insertData()==1)
        out.println("Success");
    else

        out.println("Unsuccess");
%>

code for class file in package->sample filename->Database.java…

package sample;

import java.util.*;
import java.sql.*;

public class Database
{
    private String id="",name="";
    private int t=0;
    private Connection con;

    public void setName(String name)
    {
        this.name=name;
    }

    public String getName()
    {
        return name;
    }

    public void setId(String id)
    {
        this.id=id;
    }

    public String getId()
    {
        return id;
    }

    public Connection c1()
    {
        try{
            Class.forName("oracle.jdbc.OracleDriver");
            con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1000:xe","system","12345");
        }
        catch(Exception e){}
        return con;
    }

    public int checkName(String n)
    {
        try{
            con=c1();
            PreparedStatement pst = con.prepareStatement("select name from testani where name='"+n+"'");
            t = pst.executeUpdate();
            con.close();
        }
        catch(Exception e){}
        return t;
    }

    public int insertData()
    {
        try{
            con=c1();
            PreparedStatement pst = con.prepareStatement("insert into testani values('"+name+"','"+id+"')");
            t = pst.executeUpdate();
            con.close();
        }
        catch(Exception e){}
        return t;
    }
}

I have created a database named testani with attributes name and id by using mysql…

Now how can i modify this code to generate some names…. 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-16T19:56:50+00:00Added an answer on June 16, 2026 at 7:56 pm

    I guess you need to make your own algorithm for name suggestion.

    Like once the user enters his name,surname, birth year,etc. then you can design an algorithm that can take these values and do some processing by combining(concatenating) words or birth year or anything that you want to generate suggested usernames.

    Then you can simply return that list to the user.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A site done completely in HTML now needs to have some content added to
I have a somewhat unusual issue. I've done something like this many times: $('#selector').css('color','#00f');
I have an application where users have somewhat of a settings page, and some
I currently have a somewhat working version of what I need to be done,
I have a SQL question that I could use some help with. Still somewhat
UPDATE: I have somewhat resolved the issue. Just in case if anyone runs in
I need to extract a value from a hidden HTML field, have somewhat figured
Setting up a project structure; I am thinking is it better to have somewhat
I have a somewhat strange issue with visual studio. Almost every time I create
I have a somewhat simple Client/Server solution running over C# remoting (System.Runtime.Remoting). The MarshalByRef

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.