A Web Application Accessing a Database

Write a Web application that accesses a database through JDBC.

The database should hold at least one table, for example of friends' addresses and telephone numbers (choose any comparable application). You may create the database and table(s) initially using an SQL interpretter like the mysql command.

Write a JSP page that displays contents of the key column (e.g. friends names) of the database table. The contents of the column may be displayed in an HTML table, or, more naturally, an HTML select element in a form. If you choose to display keys in an HTML table, you should also provide a separate form input element for entering a particular key.

A second JSP page should display the other column values for the selected database entry.

Add extra pages that allow entries to be added and/or editted.

You may freely adapt and modify the Web-interface-to-SQL example given in the lectures. For example you should be able display a table of keys by JSP commands something like:

  <jsp:setProperty name="sql" property="query" value="select mykey from mytable"/>

  <table border cellspacing="0" cellpadding="5">
      <%       
          while(sql.nextRow()) {
              out.println("<tr>") ;
              out.println("<td>" + sql.getColValues(0) + "</td>") ;
              out.println("</tr>") ;
          }
      %>
  </table>
using the same JavaBean as given in the lecture. Similarly, setting the query property with a scriptlet like
  <%
      sql.setQuery("select * from mytable where name=\'" + request.getParameter("name") + "\'") ;
  %>
should allow you to extract all columns in a chosen row. Alternatively you may define your own specialized Bean class, and build the SQL commands inside the methods of that class. You can cut and paste all the original source files from the course home page.

Submit all HTML, JSP, any JavaBean source, and a textual representation of your table data for grading.