Hi
I'm new to JSP. What i'm trying here is that to retrieve data from oracle database to my jsp combo boxes.
The problem is:
stage1:
I have 3 to 4 combo boxes and these combo boxes are linked with one another. for example:
This is how it should happen:
selecting combo1...triggers a query and combo2 gets it values accordingy. same for combo2 &combo3 and so on.
stage2:
i also want to update my combo box without refreshing my page.
I think it is possible by combining javascript and jsp.
Here is my jsp code for connecting to oracle
Can somebody please help me on this
Thanx
I'm new to JSP. What i'm trying here is that to retrieve data from oracle database to my jsp combo boxes.
The problem is:
stage1:
I have 3 to 4 combo boxes and these combo boxes are linked with one another. for example:
This is how it should happen:
selecting combo1...triggers a query and combo2 gets it values accordingy. same for combo2 &combo3 and so on.
stage2:
i also want to update my combo box without refreshing my page.
I think it is possible by combining javascript and jsp.
Here is my jsp code for connecting to oracle
Code:
<%@ page import="java.sql.*" %>
<HTML>
<HEAD><TITLE>My App</TITLE></HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
<B>connecting</B>
<BR><BR>
<%
Connection conn = null;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(
"jdbc:oracle:thin:@192.168.0.2:1521:orcl",
"scott",
"tiger");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM Emp");
//Print start of table and column headers
out.println("<TABLE CELLSPACING=\"0\" CELLPADDING=\"3\" BORDER=\"1\">");
out.println("<TR><TH>ID</TH><TH>NAME</TH></TR>");
//Loop through results of query.
while(rs.next())
{
out.println("<TR>");
out.println("<TD>" + rs.getString("empno") + "</TD>");
out.println("<TD>" + rs.getString("eName") + "</TD>");
out.println("</TR>");
}
out.println("</TABLE>");
}
catch(SQLException e)
{
out.println("SQLException: " + e.getMessage() + "<BR>");
while((e = e.getNextException()) != null)
out.println(e.getMessage() + "<BR>");
}
catch(ClassNotFoundException e)
{
out.println("ClassNotFoundException: " + e.getMessage() + "<BR>");
}
finally
{
//Clean up resources, close the connection.
if(conn != null)
{
try
{
conn.close();
}
catch (Exception ignored) {}
}
}
%>
</CENTER>
</BODY>
</HTML>
Can somebody please help me on this
Thanx