<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="java.sql.*"%>
<%
	Connection conn = null;
	PreparedStatement stmt = null;
	ResultSet rs = null;
	try
	{
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		conn = DriverManager.getConnection("jdbc:odbc:Presidents");
		
		String sName = "%" + request.getParameter("President") + "%";
		
		String sql = "SELECT PresidentID, FirstName, LastName FROM Presidents WHERE FirstName LIKE ? OR LastName LIKE ?";
		stmt = conn.prepareStatement(sql);
		stmt.setString(1, sName);
		stmt.setString(2, sName);
		
		rs = stmt.executeQuery();
		out.write("<ul>");
		while (rs.next()) 
		{
			out.write("<li>");
			out.write(rs.getString("FirstName") + " " + rs.getString("LastName"));
			out.write("</li>");
		}
		out.write("</ul>");
	}
	catch(Exception e)
	{
		out.write("failed:" + e.toString());
	}
	finally 
	{
		if (rs != null) rs.close();
		if (stmt != null) stmt.close();
		if (conn != null) conn.close();
	}
%>