How to show data from database in textbox in jsp

How to show data from database in textbox in jsp

How to show data from database in textbox in jsp

View Answers

June 19, 2012 at 3:28 PM

Here is an example that retrieve the particular record from the database and display it in textbox using JSP.

<%@page language="java"%>
<%@page import="java.sql.*"%>
<table border="1">
<%
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
String query = "select * from employee where id='1'";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
if(rs.next()){
%>
<tr>
<tr><td>Name</td><td><input type="text" name="name" value="<%=rs.getString("name")%>"></td></tr>
<tr><td>Address</td><td><input type="text" name="address" value="<%=rs.getString("address")%>"></td></tr>
<tr><td>Contact No</td><td><input type="text" name="contact" value="<%=rs.getInt("contactNo")%>"></td></tr>
<tr><td>Email</td><td><input type="text" name="email" value="<%=rs.getString("email")%>"></td></tr>
<%
}
}
catch(Exception e){}
%>
</table>

June 19, 2012 at 3:36 PM

Here is an example of autocompletebox in JSP. As the user tpe any letter in the textbox, corresponding values will get displayed.

1)auto.jsp:

<%@page import="java.sql.*"%>
 <html>
 <head>  
 <script language="javascript" type="text/javascript">  
 var xmlHttp  
 var xmlHttp
 function showState(str){ 
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="get.jsp";
url += "?count=" +str;
xmlHttp.onreadystatechange = stateChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
 function stateChange(){   
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){   
 document.getElementById("country").innerHTML=xmlHttp.responseText;  
 }   
 }   
 </script>  
 </head>  
 <body>  
 <input id="name" type="text" name="name" onkeyup="showState(this.value)">
 <br>  
 <div id='country'>  
 </div>  
 </body> 
 </html>

2)get.jsp:

<%@page language="java" import ="java.sql.*" %>  
 <%  
 String name=request.getParameter("count");  
 String buffer="<div>";  
 Class.forName("com.mysql.jdbc.Driver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
 Statement stmt = con.createStatement();  
 ResultSet rs = stmt.executeQuery("Select * from country where countryname LIKE '"+name+"%'");  
   while(rs.next()){
   buffer=buffer+rs.getString(2)+"<br>";  
   }  
 buffer=buffer+"</div>";  
 response.getWriter().println(buffer); 
%>

December 19, 2012 at 3:13 PM

i want to show data in text field not in any divison ....how to show it??


December 19, 2012 at 3:14 PM

means i want to autocomplete the text field using ajax. plz tell me how to do it??









Related Tutorials/Questions & Answers:
How to show data from database in textbox in jsp
How to show data from database in textbox in jsp   How to show data from database in textbox in jsp   Here is an example that retrieve the particular record from the database and display it in textbox using JSP. <
By dropdownlist retrive data from database and show in textbox in jsp.
By dropdownlist retrive data from database and show in textbox in jsp.  Hello Sir, I am doing project in jsp.I have to retrive data from database, when I select value from dropdownlist, and that data I want to show in textbox
Advertisements
how to show data in database ?
how to show data in database ?  how to show the data in the database to the user in the textbox so that user can modify it and save it again
retrieving data from database to the textbox depending upon the id in jsp
retrieving data from database to the textbox depending upon the id in jsp  Hi, our project involves fetching of data from database into textbox depending upon another textbox value which is productid.First the id entered by us
display data from database in textbox when id entered in textbox
display data from database in textbox when id entered in textbox  i wanted to enter data in textbox .depending on entered data in textbox data from database should be displayed dynamically in textbox
Getting Textbox data from database
Getting Textbox data from database  When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown... data from database and display it on the textboxes. <%@page language="java
Getting Textbox data from database
;Here is a jsp code that retrieves data from database and display...Getting Textbox data from database  When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown
How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB:student; @table:stu_info; Combobox values:(class1,class2,class3); textbox1
how to display data from database in jsp
how to display data from database in jsp  how to display data from database in jsp
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database.  Hii Sir, Lots of thnx to ur reply .I went through both... of selecting value from autocomplete textbox using jquery in jsp from mysql database
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database. ... but was unable to find out exact way to fullfill the solution of selecting value from autocomplete textbox using jquery in jsp from mysql database. Kindly send me
how to get data from database into dropdownlist in jsp
how to get data from database into dropdownlist in jsp  Can anybody tell me what is the problem in this code as i am not able to fetch the data from... tutorial go through the link JSP Get Data Into Dropdown list From Database   
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I... etc properly in the database,but what and how should i make
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I... etc properly in the database,but what and how should i make
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I... etc properly in the database,but what and how should i make
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I can update my database but i want to autogenerate tasks id in numbers on JSP
how to show effect (visual) on jsp page using value from database
how to show effect (visual) on jsp page using value from database  I am making a ticket booking system. I have a databse with a clumn "booking status... is "not_booked" then the picture shown as seat should be displayed red. Also i dont know how
how to get data from database into dropdownlist in jsp
how to get data from database into dropdownlist in jsp  //Customer Name: <select name="name"> <% try{ Class.forName...="select * from staff"; ResultSet rs=st.executeQuery(sql); while(rs.next
how to display data from jsp file into database
how to display data from jsp file into database  this is a jsp file...+",'"+email+"')"); out.println("Data is successfully inserted into database...(); in the below example. the error is "cannot convert from java.sql.Statement
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file
Solution field from database and display in the textbox of the jsp.   1...how to retreive values from MS Access Database based on the values entered in textbox values in jsp file  Hi am new to java. i need to create
how to get data from database into dropdownlist in jsp
how to get data from database into dropdownlist in jsp  Customer Name:<select name="name"> <% try{ Class.forName...=con.createStatement(); String sql="select * from staff"; ResultSet rs
How to show database values into graph using jsp?
How to show database values into graph using jsp?  How to show database values into graph using jsp
How to show database values into graph using jsp?
How to show database values into graph using jsp?  How to show database values into graph using jsp
Use of Select Box to show the data from database
Use of Select Box to show the data from database   ... from database This example will describe you the use of Select Box in a JSP page to show the data fetched from the database. We are using Servlet to get data
How we delete a data of database from front end jsp page
How we delete a data of database from front end jsp page   I make a website and featch a data from data base and now i want that a delete button put... deleted from jsp page as well as from database.I used mysql and jsp. Please help me
How to get the data from the database using Servlet or JSP program
How to get the data from the database using Servlet or JSP program  hello My Netizen friend has given the answer to retrieve data from the database... database using JSP Get data from database using JSP
how to get data using dropdownlist, textbox and search button in jsp
how to get data using dropdownlist, textbox and search button in jsp  Hi, I want to display data using jsp,javascript and mysql. My Q. is If i select...' in textbox and click on search button it should show me all the title names
How retreive data from database without using post method in jsp - JSP-Servlet
How retreive data from database without using post method in jsp  Tell me how?  Hi Friend, If you don't want to use post method then use... the selected value from the combo box and get textbox value from another page
How to Retrieve data from database in jsp
How to Retrieve data from database in jsp In this section we will discuss about how to fetch data from database table. We will give a simple example which... Here is the video tutorial of "How to retrieve data from database
How to get data from Oracle database using JSP
How to get data from Oracle database using JSP  hello i have a simple problem in jsp in the sense to get data from the database like oracle . I have... data from the database like oracle), I have created one jsp program like
how to store the data in a array retrived from the database - JSP-Servlet
how to store the data in a array retrived from the database  hi... in database,and i need to disply all the employees record in a single jsp. pls can any one tell me how to do it this using jsp. thankyou,  Hi nagaraj
Display Data from Database in JSP
, to show data from the database click on the link that calls another .jsp file named... page,that calls this jsp page and show all data from the table. ADS...; <font size="4" color="blue">show data from table<
how to add data dynamically from database into a dropdown list in a jsp
how to add data dynamically from database into a dropdown list in a jsp  hi friends i am doing a project in jsp and oracle as my database.In my... get dynamically from the database and whenever a new person has registered his
how to retrieve data from database
how to retrieve data from database  unable to retrieve data from database using mySQL by using jsp sessions and beans for editing
how to retrieve text and images from mysql database and show on html page using jsp servlet
how to retrieve text and images from mysql database and show on html page using jsp servlet  <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> Insert title here h3
JSP Get Data From Database
JSP Get Data From Database In this section we will discuss about how to get data from database using JSP. To get data from database to a JSP page we... giving a simple example which lets you understand to fetch data from database
How to show autocomplete textbox values on combo box option selection using database?
How to show autocomplete textbox values on combo box option selection using database?  When I select option(i.e First Year) then it will show list of student names in auto-complete text box
data are not display in JSP from database - JSP-Servlet
data are not display in JSP from database   i want to finding some data through a SQL query from SQL server database to a JSP page based on some... of this jsp page. like.. School Result and three request parameters 'class', 'from
how to perform operation on data retrieved from database in jsp?
how to perform operation on data retrieved from database in jsp?  i... entered marks into the database from the jsp page and i can also retrieved data from... on data retrieved from database and the present to the user PLEASE HELP ME TO SOLVE
Dynamically Update textbox from database
Dynamically Update textbox from database  I have a database as shown... to that typed value from database has to be displayed in another text box... in another textbox. How can I achieve
How you will Show all data from a table.
How you will Show all data from a table.   How you will Show all data from a table.   Hi, following query is used to show all the data of the table-ADS_TO_REPLACE_1 SELECT * FROM tablename; Thanks
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
How to access the database from JSP?
How to access the database from JSP?  Hi, What is the process of accessing the database from JSP page? Thanks   Hi, In the JSP program... database from JSP which explains you how to access the database by embedding
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
how to fetch data from mysql database table and draw a bar chart on that data using in jsp
how to fetch data from mysql database table and draw a bar chart on that data using in jsp  how to create bar chart fetch data from mysql database using in jsp.please give me a right code. yhanks in advance
dynamic retrivel of data from mysql database in table format at jsp
the data from database and display it as table format in jsp... For example, i have...dynamic retrivel of data from mysql database in table format at jsp  ... of A1 should be retrived from database and display it in the respective textbox
How to retrieve image from mysql database in JSP?
How to retrieve image from mysql database in JSP?  Hi, I need JSP... to retrieve image from mysql database in JSP? Thanks   Hi, You can write SQL query to find the data from database and get the image from resultset using

Ads