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 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









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
combo box - JSP-Servlet
combo box  how to get a combo box in jsp page which allows editing as well as list box
Advertisements
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
List Box - JSP-Servlet
list box.on selecting one value in list box,i will retrieve values from database and store into another list box in same page using javascript :location.my problem is in first list box,value which i selected to get values is not displaying
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
how to crate callout box in jsp - JSP-Servlet
how to crate callout box in jsp  how to create a callout box when pointing a link in jsp page like in MS-word document callout box. Please help me I want to use
combo box - JSP-Servlet
combo box  I am using a JSP form in which a combobox is given and I want to populate data in it from database and on the basis of yhe selected item I want to display related data in a textbox  Hi Friend, Create
JSP Text Box properties. - JSP-Servlet
JSP Text Box properties.  How do I restrict a text box created in JSP page only for numbers.. example: I have a function something like... any such in JSP. please let me know how to do it..  Hi Friend, Try
jsp list box - Java Beginners
jsp list box  I have two list boxs. the values for the first list box is retrieved from the mysql database. I want to fill the second list box...("http://localhost:8080/examples/jsp/country.jsp?id="+cid+"&&value="+val
drop down box - JSP-Servlet
drop down box  when i enter some letter in the input box,the corresponding words of that particular letter must be displayed below as a list from the data base in the same input box as drop down. Thanks&Regards, VijayaBabu.M
Javascript List Box - JSP-Servlet
itself.my problem is in list box the semester which i selected is not showing in list box as selected.when i select,the page refreshes but i get the result what i expected.i need to show in list box as semester is selected but it doesnt
Auto Complete Text Box - JSP-Servlet
Auto Complete Text Box  Please help me in Aotocomplete text box code. I m a java programmer. I m working on jsp tech. please give me the code for Autocomplete text box in which the values will generate from database table
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  For example, In Employee.jsp form, When i click employee id value in combo box...... i already stored combo box values from database. pl
display from select box - JSP-Servlet
display from select box  I am doing a jsp project. In this jsp... selection box which is in the same page. The photos are stored...://www.roseindia.net/jsp/file_upload/ http://www.roseindia.net/jsp/file_upload
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  I am using a single jsp form.. i did not get from another form.. i do not use 2 jsp form.. all.... Note: I am using only this jsp form.. i do not use
how to get combo box value - JSP-Servlet
how to get combo box value  i have created 1 servlet & 1 jsp page. in servlet page i have fired query & fetched name & its id & that i have shown in combo box in jsp page: (small part of my code) "> now i want
Auto Complete Text Box - JSP-Servlet
Auto Complete Text Box - JSP-Servlet  Auto Complete Text Box Please help me in Aotocomplete text box code. I m a java programmer. I m working on jsp tech. please give me the code for Autocomplete text box in which the values
How to retrieve data using combo box value in jsp? - JSP-Servlet
How to retrieve data using combo box value in jsp?  Hi freind, I already post this question. I need urgent help from u. pl response me... the following link: http://www.roseindia.net/jsp/comboSelect.shtml Hope
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
dependent drop down box - JSP-Servlet
the solution how to extract data from dependent drop down box with page refresh...; window.location.replace("http://localhost:8080/examples/jsp/dependentDropdown.jsp?id="+cid+"&&value...; window.location.replace("http://localhost:8080/examples/jsp/dependentDropdown.jsp
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
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
scroll bars to list box - JSP-Servlet
scroll bars to list box  Can I add scroll bars to a list box in struts?  Hi friend, Scroll the list box in struts Two attribute set "multiple" "size". Select Tag Example Select Tag
loading value into combo box by selecting value from other combo box - JSP-Servlet
loading value into combo box by selecting value from other combo box  ... is that as i select state from state_combo_box,then the next combo box is dynamically... box with constituency corresponding to district..... all three combo box
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
To get the value of more than one text box in an HTML page to a jsp page - JSP-Interview Questions
To get the value of more than one text box in an HTML page to a jsp page  An html file has a text box as To get the value of this text box in a JSP... file has a text box as To get the value of this text box in a JSP file
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
How to get data from DB in to Text box by using Jsp & Ajax
How to get data from DB in to Text box by using Jsp & Ajax   I want to get the data from database in to text box in a jsp page by using Ajax. If I enter the letter A in the textbox it should show only those values which starts
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
How to retreive data by using combo box value - JSP-Servlet
How to retreive data by using combo box value  Hello friend , i am using only one form. U are using html form and jsp form. So get...){ cid=Integer.parseInt(request.getParameter("cid")); I am using only a single jsp
How to retreive data by using combo box value - JSP-Servlet
How to retreive data by using combo box value  I am using a single jsp form.. i did not get from another form.. i do not use 2 jsp form.. all.... Note: I am using only this jsp form.. i do not use to get values from
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_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 'mythos-msg'
ModuleNotFoundError: No module named 'mythos-msg'  Hi, My Python... 'mythos-msg' How to remove the ModuleNotFoundError: No module named 'mythos-msg' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'outlook-msg'
ModuleNotFoundError: No module named 'outlook-msg'  Hi, My Python... 'outlook-msg' How to remove the ModuleNotFoundError: No module named 'outlook-msg' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'print-msg'
ModuleNotFoundError: No module named 'print-msg'  Hi, My Python... 'print-msg' How to remove the ModuleNotFoundError: No module named 'print-msg' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'print-msg'
ModuleNotFoundError: No module named 'print-msg'  Hi, My Python... 'print-msg' How to remove the ModuleNotFoundError: No module named 'print-msg' error? Thanks   Hi, In your python environment you
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 '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-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
ModuleNotFoundError: No module named 'piston-msg'
ModuleNotFoundError: No module named 'piston-msg'  Hi, My Python... 'piston-msg' How to remove the ModuleNotFoundError: No module named 'piston-msg' error? Thanks   Hi, In your python environment you
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
Acees data from database using combo box - JSP-Servlet
the data from database when i select combo box combo2 having values Arts, Commerce, Science. this combo box will appear when first combo box class_name having value 11 or 12, otherwise combo box combo2 remain hide. Here is JSP's files
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

Ads