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 a dynamic web application. Am using eclipse IDE and Apache tomcat server. i need to create a tool. Someone please kindly help me out and post your code for my following problem. My Project requirement is as follows:
I have a table in batchlogs.mdb in MS Access Database. the table structure is
Sno JobName ProgramName Problem Resolution.
1 bs001 abcd01 program got abended with 803 error illegal operation check data
And i have a jsp file which contains a textbox, name issuedescription. when user types in their issues in the textbox and click the submit button it should search in the database fields JobName, ProgramName and Problem whether any single match is found for the value in text box and if found it should retrieve the corresponding Solution field from database and display in the textbox of the jsp.
View Answers
March 27, 2012 at 5:31 PM
1)checkid.jsp:
<%@page import="java.sql.*"%>
<html>
<head>
<script type="text/javascript">
function showData(){
xmlHttp=GetXmlHttpObject()
var id=document.getElementById("id").value;
var url="id.jsp";
url=url+"?id="+id;
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null);
}
function stateChanged(){
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
var showdata = xmlHttp.responseText;
var strar = showdata.split(":");
if(strar.length>1){
var strname = strar[1];
document.getElementById("type").value= strar[1];
document.getElementById("price").value= strar[2];
}
}
}
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>
<body>
<br><br>
<table >
<tr><td>ID:</td><td><input type="text" id="id" name="id" onkeyup="showData();"></td></tr>
<tr><td>Product Type:</td><td><input type="text" id="type" name="name"></td></tr>
<tr><td>Price:</td><td><input type="text" id="price" name="address"></td></tr>
</table>
</body>
</html>
2)id.jsp:
<%@ page import="java.sql.*" %>
<%
String id = request.getParameter("id").toString();
System.out.println(id);
String data ="";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:student");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from item where itemid='"+id+"'");
while(rs.next())
{
data = ":" + rs.getString("item") + ": " + rs.getString("price");
}
out.println(data);
System.out.println(data);
}
catch(Exception e) {
System.out.println(e);
}
%>
Ads
Related Tutorials/Questions & Answers:
Advertisements
how to display values from database into table using jsp
how to display
values from database into table using jsp I want to display
values from database into table
based on condition in query,
how... the
values from database based on the bookname or authorname
entered must be display
insert values from excel file into database
the following link:
Insert
values from excel
file to
database...insert
values from excel
file into database hi i want to insert
values from Excel
file into database.Whatever field and contents are there in excel
How to pass multiple values from a servlet to JSP?
How to pass multiple
values from a servlet to
JSP? hi, I want to pass multiple
values form a servlet to
JSP.
Hw do i do that?
I am able to send one value at a time without any prb, but I am unable to carry multiple (
from two
how to fetch values from .properties to a html file
how to fetch
values from .properties to a html file I have a .properties
file with some key value pairs in it. I need to fetch the
values from this .properties
file into a html file.Please let me know
how to do
How to create file from input values in Jframe ?
How to create
file from input
values in Jframe ? hi i m doing my... text1;
void form()
{
frame=new JFrame("details you have
entered are");
JPanel... to take these details and make a
file that can be appended each time.how
edit values of database using jsp
edit
values of
database using jsp hi i want a code to edit the row
from tye
database and display in a page which containd radio buttons and drop down boxes using
jsp code
edit values of database using jsp
edit
values of
database using jsp hi i want a code to edit the row
from tye
database and display in a page which containd radio buttons and drop down boxes using
jsp code
get values from Excel to database
get
values from Excel to database hi i want to insert
values from Excel
file into database.Whatever field and contents are there in excel
file that should go to
database which exists. am using SQL Server management studio
How to update,Delete database values from jtable cells ..
How to update,Delete
database values from jtable cells .. Hello Sir, I am working on a project in which i have to fetch the
values from database... records
from the table cells by entering new
values there only ...
Sir,plz send me
How to access session values through Ajax?
How to
access session
values through Ajax? Suppose in a servlet a variable userName is kept in session.
How can I
access this variable
from JSP through AJAX? Is it possible
problem in setting the values from database
the
values from database.
here is the code:
private JTextField getJTextField1...problem in setting the
values from database hello friends,
can...");
PreparedStatement pst=con.prepareStatement("select *
from form1 where TerminalID