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



Home Answers Viewqa JSP-Servlet Name Display in alert box
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


vijayababu
Name Display in alert box
1 Answer(s)      6 years and 10 months ago
Posted in : JSP-Servlet



Advertisement
View Answers

May 19, 2008 at 9:10 PM


Hi

<!DOCTYPE HTML PUBLIC ?-//W3C//DTD HTML 4.01 Transitional//EN?>
<html>
<head>
<title>AJAX and Servlet</title>
<script language=?javascript?>
var xmlHttp;
function checkUserExist() {
var username = document.getElementById(?username?).value;
var url = ?/Ajax/AJAXCheckUserServlet?username=? + username;
if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
else if(window.ActiveXObject){
xmlHttp = new ActiveXObject(?Microsoft.XMLHTTP?);
}
xmlHttp.open(?Get?,url,true);
xmlHttp.onreadystatechange = callback;
xmlHttp.send(null);
}
function callback() {
if( xmlHttp.readyState==4 ){
if( xmlHttp.status==200 ) {
document.getElementById(?text?).innerHTML = ?<br/><b>?+xmlHttp.responseText+?</
b>?;
}
}
}
function focusIn(){
document.getElementById(?username?).focus( );
}
</script>
</head>
<body onload=?focusIn();?>
<form>
User Name <input type=?text? id=?username? name=?username? />
<input type=?button? value=?Check User Name Availability? onClick=?checkUserExist()?/>
<div id=? text? ></div>
</form>
</body>
</html>

---------------------------------------------------

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import java.sql.*;
public class AJAXCheckUserServlet extends HttpServlet {
public void doGet( HttpServletRequest request, HttpServletResponse response ) throws
ServletException, IOException {
String username = request.getParameter(?username?);
boolean isExist = check(username);
response.setContentType(?text/html?);
response.setHeader(?Cache-Control?, ?no-cache?);
if(isExist){
response.getWriter().write(?User Name exists. Please select other name.?);
}
else{
response.getWriter().write(?Congratulations....User Name is available.?);
}
}
public boolean check(String username) {
Connection con = null;
String url = ?jdbc:mysql://192.168.10.59:3306/?;
String db = ?javajazzup?;
String driver = ?com.mysql.jdbc.Driver?;
String user = ?root?;
String pass = ?root?;
boolean isExist= false;
try{
Class.forName(driver).newInstance();
con = DriverManager.getConnection(url+db, user, pass);
try{
Statement st = con.createStatement();
ResultSet res = st.executeQuery(?SELECT user_name FROM users?);
while (res.next()) {
String un = res.getString(?user_name?);
if(username.equals(un)){
con.close();
isExist = true;
break;
}
}
con.close();
}
catch (SQLException s){
System.out.println(?SQL code does not execute.?);
}
}
catch (Exception e){
e.printStackTrace();
}
return isExist;
}
}

---------------------------------



Related Tutorials/Questions & Answers:
Name Display in alert box - JSP-Servlet
Name Display in alert box  Dear Sir, Please any one help me......... when i enter some value in text that value is already in database display the alert box but the value is not in data base alert box is not display
Display two alert box alternately by clicking on text
Display two alert box alternately by clicking on text In this tutorial , we will discuss about how to display two alert box alternately by clicking on text... on it ,it will show a alert box. But when we click on it again , it shows second alert box
Advertisements
Display alert box on clicking link
Display alert box on clicking link In this tutorial, we will display alert box... is used to display alert box on clicking link : $("a").click(function... a "a href" link. On clicking this link ,a alert box prompt message
change appearance of alert box
change appearance of alert box  how to change the appearance of an alert() box
Java Alert Box
JOptionPane class to display the message alert box.  JOptionPane class is available...Java Alert Box In this example we will describe java alert box. First of all we have created class than main method after that we have created alert box
JavaScript display variable in alert
in alert box? I am using javascript.   <html> <head> <script..."; var city = "Delhi"; alert(name +" is in "+ city); } </script> <... put variable or any statement in alert which you want to display
alert box in iphone
alert box in iphone  hello, how can i show alert box in my iphone application??   hello, you can use this code for show the alert .. UIAlertView *alt = [[UIAlertView alloc] initWithTitle: @"Title" message: @"Any
Alert Box in Flex
Flex Alert Box Components Adobe Flex provides many types of components, in this tutorial we will study visual component. 1. Alert Box: In the present tutorial we will see how to display simple text using Alert Box. An Alert Box
why alert box is not appearing in servlets...?
why alert box is not appearing in servlets...?  //example.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class adduser extends HttpServlet { public void init(ServletConfig config
Flex Alert Box example
Flex Alert Box example       Alert box is a dialog box that appears on window with some... Alert & box, Alert is a class defined inside the mx.controls package
display the employee name
display the employee name  when i will select one employee designation based on that employee designation display the particular designation employee name display in another select box how it possible using servlet and mysql
To display suggestions in a text box - Ajax
:'A'), the names that starts from 'A' have to display in the text box... to display( These values should get from exisiting database). Name: A( When i...To display suggestions in a text box  Hi All, I have a requirement
how to get selected name from combo box
of worker name within d combo box and display that id into a text box. plz...how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my
how to get selected name from combo box
of worker name within d combo box and display that id into a text box. plz...how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my
how to use confirmation alert box before delete in jsp?
how to use confirmation alert box before delete in jsp?  I use submit button.I want alert box before deleting data.   1)application.jsp... method="post" name="form"> <table border="1"> <tr><th>Name<
how to get selected name from combo box
of worker name within d combo box and display that id into a text box. plz answer...how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my
how to get selected name from combo box
of worker name within d combo box and display that id into a text box. plz answer...how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my
how to get selected name from combo box
of worker name within d combo box and display that id into a text box. plz answer...how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my
alert
alert  after pressing ok button in alert message it has to stop...; if(username==""){ alert("Enter Username!"); return false; } if(password==""){ alert("Enter Password!"); return false; } return true; } </script> <
How to Display an alert message when nothing is selected in jspinner in java?
How to Display an alert message when nothing is selected in jspinner in java?  Hello, i'm trying to code a jspinner in java and i want to display... with the initial value = 0 what i want is if the user did not select the jspinner an alert
Code to store SubCombo box Name - Development process
Code to store SubCombo box Name  Hi, In the following code i want to store Sub-combo box(Second combo in Department field) name instead of value. plz send me code tfor that Add Data var arr = new Array(); arr["Select
jQuery alert()
box can display information. This example displays an alert box after clicking...jQuery alert() In this jQuery tutorial we will discuss how an alert box works in jQuery. Moreover, this tutorial will discuss in details about alert box
depending on the form name i have to display the message
depending on the form name i have to display the message  depending on the form name i have to display the message. for example, i have 3 jsp pages... on contact us after entering all details page has to display message like"thank u
Automatically display in text box - JSP-Servlet
Automatically display in text box  Dear Deepak Sir, When i enter some text in text box.That corresponding value in database,the value display in another text box using ajax. Thanks & Regards, VijayaBabu.M
how to display the value of termcell name in label
how to display the value of termcell name in label  want to display the tercell name in label report of pending apllication of termcellname code...="display"%> <%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html"%> <
If statement doesn't work ,(doesn't print alert message when user dont field name and email)
If statement doesn't work ,(doesn't print alert message when user dont field name and email)  I've created some if / else statements to get a download when a user hit click jf he fields name and email but doesn"t work for my site
how to display webservice response in a text box
how to display webservice response in a text box  Hallo, i have created a webservice and when i sended request to my webservice its sending proper response . the point is how to dispaly the response values in a text box usinj
How to set left and top positions of alert box using JQuery in the below code?
How to set left and top positions of alert box using JQuery in the below code...=Update name=theButton onclick=open_faxaddress('+cusno+') style=background-color: #888; color: #FFF;/> <input type=button value=Cancel class=button name
Display the column name using DBCP
;Columns Name: ");         ...;    System.out.println(col_name);     
display from select box - JSP-Servlet
display from select box  I am doing a jsp project. In this jsp project i have to show the photos in one cell depending on the selection from other selection box which is in the same page. The photos are stored
how to display(update) current date and month in select box on selecting the year.
how to display(update) current date and month in select box on selecting the year.  how to display(update) current date and month in select box on selecting the year
 

 

 

DMCA.com