<%@ page import="java.io.*, java.lang.*, java.sql.*" %> <%! // Declarations String catID, categoryName; StringBuffer sites, categories; %> <% Connection con; Statement s; ResultSet rs; String line, desc; try { // Establish database connection Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection( "jdbc:mysql://localhost/phos", "cklutzke", "periadon"); s = con.createStatement(); // Determine category catID = request.getParameter("catID"); if (catID == null) { catID = "0"; } // Get the category name from the database. rs = s.executeQuery("SELECT c.name FROM category AS c " + "WHERE c.categoryId = '" + catID + "'"); while (rs.next()) { categoryName = rs.getString("c.name"); } rs.close(); // Get the category list from the database. categories = new StringBuffer("

Categories

"); // Get the site list from the database. sites = new StringBuffer("

Sites

"); s.close(); con.close(); } catch (ClassNotFoundException e1) { // JDBC driver class not found, print error message to the console out.println(e1.toString()); } catch (SQLException e2) { // Exception when executing java.sql related commands, print error message to the console out.println(e2.toString()); } catch (Exception e3) { // other unexpected exception, print error message to the console out.println(e3.toString()); } %> Carl's Link Database: <%= categoryName %>

<%= categoryName %>

LinkDb > [todo: link chain goes here]

<%= categories %> <%= sites %>