msg box in jsp

Ads
 

msg box in jsp

i need the source code to display the msgbox in jsp....but one condition is,i need to use it in the current page itself...now i use the message box means it prints it into another page...i need to resolve it plz try to help me..

View Answers

April 7, 2011 at 12:36 PM

1)login.jsp:

<html>
<head>
<script type="text/javascript">
function showData(){ 
    var user=document.getElementById("username").value;
    var pass=document.getElementById("password").value;
xmlHttp=GetXmlHttpObject()
var url="checkajax.jsp";
url=url+"?user="+user+"&&pass="+pass;
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged(){ 
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
    var showdata = xmlHttp.responseText; 
    alert(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>
<form name="form">
<table>
<tr><td>Username:</td><td><input type="text" id="username"></td></tr>
<tr><td>Password:</td><td><input type="password" id="password"></td></tr>
<tr><td></td><td><input type="button" value="Submit" onclick="showData();"></td></tr>
</table>
</form>
</html>

2)checkajax.jsp:

<%@ page import="java.sql.*" %> 
<%
String user = request.getParameter("user");
String pass = request.getParameter("pass");
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='"+user+"' and password='"+pass+"'");
          int count=0;
          while(rs.next())
          {

                   count++;
          }

                    if(count>0)
          {
             data="Welcome User!";
          }
          else
          {
                      data="Username or Password is Invalid!";
          }

out.println(data);
System.out.println(data);
}
catch (Exception e) {
System.out.println(e);
}
%>

July 3, 2011 at 10:38 PM

it is tough to understand the code simply i need is first i have to validate whether all the fields are filled . if filled it has to move to the corresponding jsp file else it has to show an alert box that the particular field is not filled

Ads









Related Tutorials/Questions & Answers:
msg box in jsp
msg box in jsp  i need the source code to display the msgbox in jsp....but one condition is,i need to use it in the current page itself...now i use the message box means it prints it into another page...i need to resolve it plz
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
Advertisements
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
populating text box using jsp code
populating text box using jsp code  Sir, How to populate related values in a text box after selecting value from drop down list using JSP and mysql.... Please give an example using jsp code only.   dependentDropdown.jsp
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  Hi Friends, When i click combobox value in jsp form page, it will diplay...... For Example, in Student.jsp... when i click student id in combo box
retrive the data from access database to drop down list box in jsp
retrive the data from access database to drop down list box in jsp  hai, im new to jsp now im using the jsp along with access database.in table i load all the data's i need to retrive the data from database to dropdown list box
To Retain the values entered in the text box after submit in jsp page
To Retain the values entered in the text box after submit in jsp page   i am working on a jsp pge which has many text boxes and one dynamic drop... box , data is retreived from the database and displayed in table format. I have
Retrieving data from data base using jsp combo box
Retrieving data from data base using jsp combo box  Hi guys please help me , i have on GUI page int that Server type(like apache,jboss,weblogic) one combo box is there and another filed is version of the server(like 1.0,2.0) like
How to get the values from the Combo Box - JSP-Servlet
, Actually i am getting the values in the combo box from table.I want what ever the value i select in combo box its corresponding records will display in their respective text box. e.g suppose i select ram values from the combo box and its
How to implement ajax in struts2 to operate on select box in jsp
How to implement ajax in struts2 to operate on select box in jsp  I am doing a project on struts2 in which i have a jsp page which has 2 select boxes... by assigning to block list select box... plz help me .. its urgent .. thanx in advance
Insert value of dynamic generated text box in jsp using javascript
Insert value of dynamic generated text box in jsp using javascript  hello sir , i want to generate dynamic text box at run time and i did that using... that dynamically generated text box value into database at a time without
jsp login code ... when username , drop down box and password is correct
jsp login code ... when username , drop down box and password is correct  i need a jsp code for login.... when username password and dropdown box value is correct.... the drop down box values should be retrieved from database
jsp login code when username , password and dropdown box value is correct...
jsp login code when username , password and dropdown box value is correct... in dropdown box.... so when i login i all the three username,password and dropdown box........ but in the drop down box ... i need to get the values from backend
jsp login code when username , password and dropdown box value is correct...
jsp login code when username , password and dropdown box value is correct...  my project has login in whic i should select the company name in dropdown box.... so when i login i all the three username,password and dropdown box
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... = '"+no+"'"); response.sendRedirect("/examples/jsp/application.jsp"); } catch(Exception e
how to prevent no from unroundin off on clicking text box again in JSP and Jquery
how to prevent no from unroundin off on clicking text box again in JSP and Jquery  I am rounding off numbers entered in a text box in jsp but when I... on clicking on that text box again in Jquery and JSP. Thanks
jsp code for a drop down box to retrive value from database
jsp code for a drop down box to retrive value from database  my project needs to get the value from database in to the drop down box..... pls give me code for that ..... tan q   1)login.jsp: <html> <script>
How to "Get data froom MySQL DB on giving a value in a tex-box in a JSP file."
How to "Get data froom MySQL DB on giving a value in a tex-box in a JSP file..." in a text-box in a JSP file. Ex:dept table; if we give dept_no in a text-box in JSP... it in the same JSP file. Help me plz
populating one dropdown box depending on the value of other using jsp
populating one dropdown box depending on the value of other using jsp  HI i have scenario i need to populating one dropdown box depending... in dropdown box one after the other CREATE TABLE CITY_MASTER( CITYID BIGINT
how to display data from mysql table in text box using jsp??
how to display data from mysql table in text box using jsp??  <p>hi, i have a written a code to display data from a mysql table into txtboxes... at line: 113 in the jsp file: /Cat1.jsp The local variable v_RGPC may not have
ModuleNotFoundError: No module named 'msg'
ModuleNotFoundError: No module named 'msg'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'msg' How to remove the ModuleNotFoundError: No module named 'msg' error
add text box and select list dynamically and get its value to store it into database using jsp request parameter
added select box also into next jsp page plz reply me as early as posssible...add text box and select list dynamically and get its value to store it into database using jsp request parameter  its very helpful when you have only
retrieving from oracle database using jsp combo box
retrieving from oracle database using jsp combo box  hi this is my code in this once i select the server type and version of the server the process name of the server has to display in the process name field from the oracle
sir plz help in design a jsp page whichis as follow username [_____] select [__>]password [_____] after selection then onlypassword text box is visible
sir plz help in design a jsp page   sir plz help in design a jsp page which is as follow username [ _ ] select [ > ] password [ _ ] after selection then only password text box is visible
ModuleNotFoundError: No module named 'extract-msg'
ModuleNotFoundError: No module named 'extract-msg'  Hi, My Python... 'extract-msg' How to remove the ModuleNotFoundError: No module named 'extract-msg' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'extract-msg'
ModuleNotFoundError: No module named 'extract-msg'  Hi, My Python... 'extract-msg' How to remove the ModuleNotFoundError: No module named 'extract-msg' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'lyw-msg'
ModuleNotFoundError: No module named 'lyw-msg'  Hi, My Python...-msg' How to remove the ModuleNotFoundError: No module named 'lyw-msg... to install padas library. You can install lyw-msg python with following command
ModuleNotFoundError: No module named 'msg_client'
ModuleNotFoundError: No module named 'msg_client'  Hi, My Python... 'msg_client' How to remove the ModuleNotFoundError: No module named 'msg... have to install padas library. You can install msg_client python
ModuleNotFoundError: No module named 'msg-parser'
ModuleNotFoundError: No module named 'msg-parser'  Hi, My Python... 'msg-parser' How to remove the ModuleNotFoundError: No module named 'msg... have to install padas library. You can install msg-parser python
ModuleNotFoundError: No module named 'msg_serv'
ModuleNotFoundError: No module named 'msg_serv'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'msg_serv' How to remove the ModuleNotFoundError: No module named 'msg_serv
ModuleNotFoundError: No module named 'msg-topgen'
ModuleNotFoundError: No module named 'msg-topgen'  Hi, My Python... 'msg-topgen' How to remove the ModuleNotFoundError: No module named 'msg... have to install padas library. You can install msg-topgen python

Ads