<Jsp: useBean id = "mybbs" scope = "session" class = "netzero. mydb"/>
<% @ Page contentType = "text/html; charset = gb2312" %>
<% @ Page import = "java. io. *" %>
<% @ Page import = "java. SQL. *" %>
<%
Int intRowCount;
Out. print ("display Forum tree structure ");
Out. print ("<br> ");
Try {
String SQL = "select * from mybbslist order by rootid desc, depth, fid, bbsid ";
ResultSet rs = mybbs.exe cuteQuery (SQL );
If (rs. next ())
{
Rs. last ();
IntRowCount = rs. getRow ();
Out. print ("in the Forum Tree ");
Out. print (intRowCount );
Out. print ("leaf nodes ");
Rs. first ();
Int j = 0;
Int Depth = 0;
Out. print ("<ul> ");
While (j <intRowCount)
{
Int rsDepth = rs. getInt ("Depth ");
If (rsDepth <Depth)
{
For (int I = 1; I <Depth + 1; I = I + 1)
{
Out. print ("</ul> ");
}
}
RsDepth = rs. getInt ("Depth ");
If (rsDepth> Depth)
{
Out. print ("<ul> ");
}
Out. print ("<li> ");
String bbssubject = rs. getString ("bbssubject ");
Out. print (bbssubject );
Out. print ("</li> ");
Depth = rs. getInt ("Depth ");
J = j + 1;
Rs. next ();
}
Out. print ("</ul> ");
}
Else
{
Out. print ("no record in Database ");
}
} Catch (SQLException E ){
Out. println ("SQLException:" + E. getMessage ());
Out. println ("SQLState:" + E. getSQLState ());
Out. println ("VendorError:" + E. getErrorCode ());
}
%>
<% // Close the mysql connection
Try {
If (! Mybbs. closeConn ());
} Catch (Exception ex ){
System. err. println ("closeConn:" + ex. getMessage ());
}
%>