Hi guys!!!

I have 3 tables Projetos, ALunos e Componentes_projetos

Table Alunos

- id_alunos
- nome

Table Projetos

- id_projetos
- titulo
- andamento

Table componentes_projetos (It links alunos and table projects)

id_componentes_projetos
id_projetos
id_alunos

When you register a project, this project may have several components (students). So I register these students in the table and say componentes_projetos of which project it belongs.

Ok, this has been done.

I have a link bancas.jsp I do the scheduling of a project that is saved in the bank.
So I have to submit a list of the components of the project that I requested.

What better way for me to do this?
follows the code I am currently doing but is not returning anything:

cadastrar-bancas.jsp

Java Code:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>  
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"  uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>SCB - Painel de Administração</title>
<%@ include file="header.jsp" %> 
</head>
<body>

<%@ include file="top.jsp" %>


<!-- Content wrapper -->
<div class="wrapper">
	
	<%@ include file="menu.jsp" %>
	
	<!--MELHORAR A VALIDAÇÃO AQUI-->
    
	<div class="success message">
		<s:if test="hasActionMessages()">
			<s:actionmessage/>
		</s:if>	
	</div>
    
    <jsp:useBean id="dao_projetos" class="br.com.scb.dao.ProjetoDAO" />
    <jsp:useBean id="dao_professores" class="br.com.scb.dao.ProfessorDAO" />
    <jsp:useBean id="dao_componentes" class="br.com.scb.dao.ComponenteDAO" />
    
    <!-- Content -->
    <div class="content">
    	<div class="title">
    	  <h5>Bancas</h5></div>
        
        <form action="buscaBanca" method="post" class="mainForm">
        
      <div class="widget first">
            <div class="head">
              <h5 class="iList">Cadastrar Bancas - <strong>${projetos.titulo}</strong></h5></div>
           
            <div class="rowElem">
                <label>Data da defesa:</label>
                <div class="formRight">
                    <input type="text" name="banca.data_defesa" class="datepicker" />
                </div>
                <div class="fix"></div>
            </div>
            
            <div class="rowElem">
              <label>Componentes do Grupo:</label>
              <div class="formRight">
                  <span class="floatleft w40">
                      <select name="grupo" multiple="multiple" class="multiple" id="grupo" style="height:100px;">
	                      <c:forEach var="componentes" items="${dao_componentes.lista}"> 
                        	<option value="${componentes.id_projetos}">${componentes.id_projetos}</option>
	                      </c:forEach>
                      </select>
                </span>
              </div>
              <div class="fix"></div>
            </div>
            
            <div class="rowElem">
              <label>Orientador:</label>
              <div class="formRight">
                <input name="matricula2" type="text" value="${projetos.professorNome}"/>
              </div>
              <div class="fix"></div>
            </div>
            
              <div class="fix"></div>
            </div>
            <!--FIM COMPONENTE-->
            
				<input type="submit" value="Cadastrar" class="basicBtn submitForm mb22" />
              <div class="fix"></div>

        </div>
        
        </form>
    </div>
    <div class="fix"></div>
</div>

<!-- Footer -->
<%@ include file="footer.jsp" %> 


</body>
</html>
BuscaBancaAction.java

Java Code:
package br.com.scb.action;

import java.util.List;

import br.com.scb.dao.ComponenteDAO;
import br.com.scb.dao.ProjetoDAO;
import br.com.scb.modelo.Componente;
import br.com.scb.modelo.Projeto;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

public class BuscaBancaAction {
	
	private String id_projetos;
	private Projeto projetos;
	private List<Componente> componente;
	

	public List<Componente> getComponente() {
		return componente;
	}

	public void setComponente(List<Componente> componente) {
		this.componente = componente;
	}

	public void setId_projetos(String id_projetos) {
		this.id_projetos = id_projetos;
	}
	
	public Projeto getProjetos(){
		return projetos;
	}
	
	@Action(value="buscaBanca", results = {
			@Result(name = "ok", location="/cadastrar-bancas.jsp")
	})
	
	public String execute(){
		projetos = new ProjetoDAO().buscaPorId(id_projetos);
		componente = new ComponenteDAO().getLista(id_projetos);
		return "ok";
	}

}
ComponenteDAO.java

Java Code:
package br.com.scb.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import br.com.scb.jdbc.ConnectionFactory;
import br.com.scb.modelo.Componente;

public class ComponenteDAO {
	private final Connection connection;
	
	public ComponenteDAO(){
		connection = new ConnectionFactory().getConnection();
	}
	
	public void adiciona(Componente componentes, String uuID) {
		final String sql = "INSERT INTO componentes_projetos (id_alunos, id_projetos) values (?,?)";
		PreparedStatement stmt;		
		
		String[] split = componentes.getId_alunos().split(",");
		
		for(String id_alunos : split){			
			try {
				stmt = connection.prepareStatement(sql);
				stmt.setString(1, id_alunos.trim());
				stmt.setString(2, uuID);
				stmt.execute();
			} catch (SQLException e) {
				throw new RuntimeException(e);
			}
		}
		
	}
	
	public Componente buscaPorComponente(String id_projetos) {
		try {
			PreparedStatement stmt = this.connection.prepareStatement("SELECT * FROM componentes_projetos WHERE id_projetos = ?");
			stmt.setString(1, id_projetos);

			ResultSet rs = stmt.executeQuery();

			if(rs.next()) {
				
				Componente componente = new Componente();
				
				componente.setId_alunos(rs.getString("id_alunos"));
				componente.setId_projetos(rs.getString("id_projetos"));
				
				return componente;				
			}

			rs.close();
			stmt.close();

			return null;
		} catch (SQLException e) {
			throw new RuntimeException(e);
		}
	}
	
	
	public List<Componente> getLista(String id_projetos) {
		try {
			List<Componente> componentes = new ArrayList<Componente>();
			PreparedStatement stmt = this.connection.prepareStatement("SELECT * FROM componentes_projetos WHERE id_projetos = ?");
			stmt.setString(1, id_projetos);

			ResultSet rs = stmt.executeQuery();

			while(rs.next()) {
				Componente componente = new Componente();

				componente.setId_alunos(rs.getString("id_alunos"));
				componente.setId_projetos(rs.getString("id_projetos"));

				componentes.add(componente);
			}

			rs.close();
			stmt.close();

			return componentes;
			
		} catch (SQLException e) {
			throw new RuntimeException(e);
		}
	}


}