<%@ page  session="true"  contentType="text/html; charset=ISO-8859-1"%>
<%@ page import = "uy.edu.udelar.forrest.forrestloganalyser.webapp.ConsultasBase" %>
<%@ page import = "java.util.Iterator" %>
<%@ page import = "java.sql.ResultSet" %>
<%
  ResultSet datos = ConsultasBase.consultar(request.getParameter("Consulta"));
%>

<html>
<head>
  <title>Forrest Log Analyser Consultancy System - UDELAR - INCO</title>
</head>
<body bgcolor="#7099C5">
  <h2>Consultas Sobre las Tablas Base</h2><p/>
  <form method=POST action="consTablasBase.jsp">
    <table border="1" bgcolor="#7099B5">
      <tr>
        <td colspan="2">
          <textarea name="Consulta" cols="50" rows="5">
	      <%if (request.getParameter("Consulta") != null) {%>
	          <%=request.getParameter("Consulta")%>
              <%}%>
	  </textarea>
        </td>
      </tr>
      <tr>
        <td>
          <input type="submit" name="Aceptar" value="Aceptar"/>
        </td>
	<td>
	  <a href="paginas/index.html" target="_blank">
	  Consultas sobre tablas base
	  </a>
	</td>
      </tr>
    </table>
  </form>
  <% if (datos != null){
       %>
       <table border="1" bgcolor="#7099B5">
       <tr>
       <%
       int cantColumn = datos.getMetaData().getColumnCount();
       for (int i=1;i<=cantColumn;i++){
       %>
       <th>
       <%=datos.getMetaData().getColumnName(i)%>
       </th>
       <%
       }
       %>
       </tr>
       <%
       while (datos.next()){
       %>
       <tr>
       <%
         for (int j=1;j<=cantColumn;j++){
	 %>
	 <td>
	 <%=datos.getString(j)%>
	 </td>
	 <%
         }
       %>
       </tr>
       <%
       }
       %>
       </table>
  <%
     }
  %>
</body>
</html>
