hello everyone,
i am new to
JSP. I am having a drop down combo box names as "fname". When I will select any value from the drop down combo, than in the SAME PAGE only, i want to display same data in table retrieving from database. the database i.e. the table is in MS Access.
I have made the connection and can retrieve data from databse (as i have tried out in different JSP file). but i nedd to display the table in the same page when i will select a data from the combo. for different value selected different data will be displayed after retrieving from table. i cannot use any thing other than this.
i cannot use
servlet or SQL, as the specification is like this.
my code is ::-
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" %>
<%@ page import ="java.sql.*" %>
<%
try {
String dataSourceName = "prodTest";
String dbURL = "jdbc:odbc:" + dataSourceName;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String sTable = "production_dept";
String sSql = "SELECT FacultyName FROM " + sTable;
Connection cn = null;
Statement st = null;
ResultSet rs = null;
cn = DriverManager.getConnection(dbURL,"","");
st = cn.createStatement();
rs = st.executeQuery( sSql );
ResultSetMetaData rsmd = rs.getMetaData();
int n = rsmd.getColumnCount();
%>
<% String FacultyCombo = null;%>
<select name="fname" id= "fname" tabindex="20" onchange=" ">
<option VALUE=0>Choose Faculty Name</option>;
<%
while(rs.next())
{
FacultyCombo = rs.getString("FacultyName");%>
<option value='<%=FacultyCombo%>'><%out.println(FacultyCombo);%></option>
<% } %>
</select>
<% }
catch (Exception err) {
out.println("ERROR to be shown here: " + err);
}
%>
please reply soon. it is very urgent.