NavigationBar naviBar = new NavigationBar();
naviBar.add("Home","home_int.jsp");
naviBar.add("Companies Menu","companies_int.jsp");
naviBar.add("Help","help_int.jsp");
str.append(naviBar.toHTML());
// Display the page title
MyHTML.insertTitle(str,"List of All Companies",2);
// Instantiate a new database connection JavaBean
MyDbBean dbBean= new MyDbBean();
try {
// Perform the database query to get the list of companies
dbBean.connect();
ResultSet rs = dbBean.execSQLQuery("SELECT ComID,ComName, "+
"ComLicense,ComActive FROM Company ORDER BY ComName");
// Use the MyHTML class to generate a formatted table from the
// result set
String[] labels={"ComID","Company Name","License #","Active"};
MyHTML.createHyperlinkDataTableWithID(
str, labels, rs, 2,"ComID","company_details_int.jsp");
}
// Perform exception handling
catch(SQLException e) {
MyHTML.createDatabaseReport(str,MyHTML.ERROR,
"A database error has occured.
"+e);
}
catch(ClassNotFoundException e) {
MyHTML.createDatabaseReport(str,MyHTML.ERROR,
"The database driver could not be found.
"+e);
}
finally {
try {
// close the database connection
dbBean.close();
}
catch(SQLException e) {
MyHTML.createDatabaseReport(str,MyHTML.ERROR,
"The database connection could not be closed!
"+e);
}
}
// Add the disclaimer
MyHTML.includeHTMLFile(str,"disclaimer.html");
MyHTML.endPage(str);
// Get print writer of the servlet output stream
PrintWriter out = res.getWriter();
// Post the results by printing the string buffer to the output stream
res.setContentType("text/html");
out.println(str);
out.close();
}
}
68 




Java Web Hosting Application Development Using Java Technologies Hosting




 
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved.