My jsp page is:
<![CDATA[<%@page contentType="text/html" pageEncoding="UTF-8"%>]]>
<![CDATA[<%@page language="java" import="java.util.*" %>]]>
<![CDATA[<%@page language="java" import="java.sql.*" %>]]>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="skin.css">
<title>JSP Page</title>
</head>
<body>
<div>
<%
ArrayList list = new ArrayList();
ArrayList sublist = new ArrayList();
try {
Class.forName("oracle.jdbc.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/ORCL", "PORDFW", "PORDFW");
%>
<ul>
<%
String query1 = "select * from tbl_category";
Statement st1 = con.createStatement();
ResultSet rs1 = st1.executeQuery(query1);
while (rs1.next()) {
%>
<li>
<a href="#">
<%= rs1.getString("category_name")%>
</a>
<ul>
<%
String query2 = "select subcategory_name from tbl_subcategory where category_id='" + rs1.getString("category_id") + "'";
Statement st2 = con.createStatement();
ResultSet rs2 = st1.executeQuery(query2);
while (rs2.next()) {
%>
<li>
<a href="#">
<%= rs2.getString("subcategory_name")%>
</a>
</li>
<%
}
%>
</ul>
</li>
<%
}
%>
</ul>
<%
} catch (Exception e1) {
}
%>
</div>
</body>
</html>
</link>
my database has 2 tables:
1. tbl_category - > category_id, category_name
2. tbl_subcategory - > subcategory_id, category_id, subcategory_name
First table has 2 values as
Category_id Category_name
------------ --------------
1 Sports
2 Books
Second table values,
Subcategory_id Category_id Subcategory_name
-------------- ------------ -----------------
1 1 Cricket
2 1 Football
3 2 Science
4 2 Maths
My CSS :
ul {
font-family: Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
}
ul li {
display: block;
position: relative;
float: left;
}
li ul {
display: none;
}
ul li a {
display: block;
text-decoration: none;
color: #ffffff;
border-top: 1px solid #ffffff;
padding: 5px 15px 5px 15px;
background: #2C5463;
margin-left: 1px;
white-space: nowrap;
}
ul li a:hover { background: #617F8A; }
li:hover ul {
display: block;
position: absolute;
}
li:hover li {
float: none;
font-size: 14px;
}
li:hover a { background: #617F8A; }
li:hover li a:hover { background: #95A9B1; }
ul li.next {
position: absolute;
display: block;
float: left;
background:#E8E8E8;
font-size: 14px;
border-top: 1px solid #ffffff;
padding: 5px 15px 5px 15px;
}
ul li a.first {
background: #617F8A;
}
When i run this jsp, i am getting the menu as:
Sports
> Cricket
> Footbal
I am not getting the second menu "Books" with its submenu....
Pls help me...
Thanks in advance..