Options em JSP

1 resposta
Arthur_Laender

ESTO COMEÇANDO AGORA EM JSP E ESTOU COM UMA DUVIDA DE COMO COLOCAR A JANELA DE OPÇÕES NO CODIGO ABAIXO. OS RESULTADOS DO BANCO DE DADOS ESTA IMPRIMINDO CERTINHO NA TELA, MAIS NAO EM FORMA DE OPÇÃO.

<%@ page language="java" %>   
<%@ page import="java.sql.*"%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Prefeitos Mais Votados</title>
    </head>
    <body bgcolor="#CDC9C9">
        <center>
            <h1>Prefeitos Mais Votados</h1>
            <h3>Escolha a Cidade</h3>
            <%
              Connection con;
              Statement stm;
              ResultSet res;
              try {
                  Class.forName("com.mysql.jdbc.Driver");
                  con=DriverManager.getConnection("jdbc:mysql://localhost/resul_eleicoes","root","");
                  stm=con.createStatement();
                  res=stm.executeQuery("select nome from cidades order by nome");
                  while(res.next()) {
                      %>
                        <option value="<%=res.getString("nome")%>"><%=res.getString("nome")%></option>
                      <%
                  }
              } catch(SQLException e) {
              } catch(ClassNotFoundException e) {
              }
            %>
        </center>
    </body>
</html>

1 Resposta

Arthur_Laender

CONSEGUIR SOLUCIONAR O PROBLEMA, FALTAVA ABRIR E FECHAR A SELECT.

%> <select name="opcoes"> <% while(res.next()) { %> <option value="<%=res.getString("nome")%>"><%=res.getString("nome")%></option> <% } %> </select> <%

Criado 24 de outubro de 2008
Ultima resposta 24 de out. de 2008
Respostas 1
Participantes 1