I want to fill a Drop-downlist with a list look heres my list code

public List ListaEmpresas(){
        
        SessionFactory factory = HibernateUtil.getSessionFactory();
         Session session = factory.openSession();
         Transaction transaction = null;
         transaction = session.beginTransaction();
    
      
         Criteria crit = session.createCriteria(Empresas.class);
         
         
         List empresas = crit.list();
         
           List list = new LinkedList();    // Doubly-linked list
         list = new ArrayList();
        
         for(Iterator it = empresas.iterator();it.hasNext();){
           
             Empresas empre = (Empresas) it.next();
              
           list.add(empre.getEmpresaId());
       
                                   
             
             
         }
         
          return   list;
         
        }

now i want use that list to fill the Drop-downlist in a JSP page with this list here my jsp code

<body>
            <jsp:useBean id="Empresas" scope="page" class="persistencia.Empresas" />
        <form name="formulario" action="empresaagregada.jsp" method="POST">
            <table border="1">
                <thead>
                    <tr>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Cliente Id</td>
                        <td><input type="text" name="ClienteId" value="" /></td>
                    </tr>
                    <tr>
                        <td>Empresa Id</td>
                        <td><select name="EmpresaId">
                               <%
                               
                               MantenimientoEmpresas  lista = new MantenimientoEmpresas();
                                List empresas = lista.ListaEmpresas();
                               %>
                            <%   
                              persistencia.Empresas empresa = null;
                               
                                Iterator  iterador = empresas.iterator();
                                 %>
          <% while (iterador.hasNext()){
              String opcion = iterador.next().toString();
    
    %>
            <option><% out.println(" "+ opcion%></option> 
  
  
  
  <% }%>
             
                          
                               
             </select> </td>
              </tr>
                    <tr>
                        <td>Clave</td>
                        <td><input type="text" name="pass" value=""  /></td>
                    </tr>
                    <tr>
                        <td>Nombre</td>
                        <td><input type="text" name="Nombre" value=""  /></td>
                    </tr>
                    <tr>
                        <td>Apellido</td>
                        <td><input type="text" name="Apellido" value="" /></td>
                    </tr>
                     <tr>
                        <td>Telefono</td>
                        <td><input type="text" name="Telefono" value="" /></td>
                    </tr>
                     <tr>
                        <td>Area</td>
                        <td><input type="text" name="Apellido" value="" /></td>
                    </tr>
                     <tr>
                        <td>Nivel</td>
                        <td><select name="Nivel"  >
                                <option >1</option>
                                <option >2</option>
                                <option>3</option>
                                <option>4</option>
                                <option>5</option>
                            </select> </td>
                    </tr>
                    <tr>
                        <td><input type="submit" value="Enviar" /></td>
                       
                    </tr>
                    
                </tbody>
            </table>

        </form>    
    </body>

but it doesnt work the Drop-downlist doesnt print the items of the list

any example to do this?

thx

never mind is working now with the same code i posted weird thx anyway.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.