How to capture data from a table inside a form in a jsp?

0

I really need your help to solve a problem.

I have a table inside a form in a jsp. I need to upload a note and send the number of the note and the date of issue to the controller class. It happens that I can only do the operation with the first row of the table, if I try to capture any other line the application passes the data of the first line and gives an error. I really need a tip. Thank you. Every tip is welcome.

Follow the code:

Table code in the JSP:

<form action="usucontroller.do?acao=selecionar" method="post" enctype="multipart/form-data">    

    <div class="container theme-showcase" role="main" >      
    <div class="page-header" >

      </div >
      <div class="row">
        <div class="col-md-12">


          <table class="table" >

            <thead>
              <tr>

                <th>Loja</th>  
                <th>Nota</th>
                <th>Serie NF</th>
                <th>Emissao</th>
                <th>Valor</th>
                <th>Forneceodor</th> 
                <th>CGO</th>
                <th>Usuario</th> 
                <th>Status</th>
                <th>Selecao</th>  

              </tr>
            </thead>
            <tbody>


            <c:forEach items= "${requestScope.listaDados}" var ="usu">


                <tr>
                <td><input type ="text" class="form-control"  name = "nroempresa" value ="${usu.numeroEmpresa}" size ="1"/></td>
                <td><input type ="text" class="form-control"  name = "txtNumeroNF" value ="${usu.numeroNF}" size = "3"/></td>
                <td><input type ="text" class="form-control"  name = "nroserie" value ="${usu.serieNf}" size = "1"/></td>
                <td><input type ="text" class="form-control"  name = "txtEmissao" value ="${usu.dataEmissao}" size ="8"/></td>
                <td><input type ="text" class="form-control"  name = "valor" value ="${usu.valor}" size ="3"/></td>
                <td><input type ="text" class="form-control"  name = "codfor" value ="${usu.codigoFornecedor}" size ="2"/></td>
                <td><input type ="text" class="form-control"  name = "cgo" value ="${usu.cgo}" size ="2"/></td>
                <td><input type ="text" class="form-control"  name = "responsavel" value ="${usu.usuarioFaturou}" size ="13"/></td>
                <td><input type ="text" class="form-control"  name = "status" value ="${usu.enviado}" size ="1"/></td>
                <td>

                  <a href="usucontroller.do?acao=selecionar"><input type="file" accept="image/*" class="btn btn-default" name = "imagem"><br/></a>  
                  <input type="submit"  value="ENVIAR">      

               </td>
                </tr>


             </c:forEach>   


            </tbody>


          </table>


        </div>
        </div>
    </div> 

    </form>

Uploading controler class

    public int fazerUpload(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
            int controle = 1;

                numeroNf = request.getParameter("txtNumeroNF");
                dataEmissao = request.getParameter("txtEmissao");

                if(numeroNf != null && numeroNf !=""){
                   notaFiscal = Integer.parseInt(numeroNf);
                } 

           //Pegando a pasta do projeto
           String pastaProjeto = getServletContext().getRealPath("");
           ConsultaDAO dao = new ConsultaDAO();

           //Definir o caminho completo da pasta das imagens
           String salvarEm = pastaProjeto + File.separator + pastaImagens;
           System.out.println("Salvando o arquivo em :" + salvarEm);

           //Verificar se a pasta existe, se nao e criada
           File pasta = new File(salvarEm);
           if(!pasta.exists()){
               //Criar a pasta
               pasta.mkdirs();
           }

            //Pegar o arquivo selecionado
           Part arquivoSelecionado = request.getPart("imagem");


           String nomeArquivo = null;

           if(arquivoSelecionado != null){
            nomeArquivo = arquivoSelecionado.getSubmittedFileName();

    //      }

           String dataSistema = capturarDataSistema();

            HttpSession sessao = request.getSession(); //Verficar se deu certo
            Usuario usuarioLogado = (Usuario)sessao.getAttribute("usuLogado"); //Verificar se deu certo




           try {    //controle, notaFiscal, dataEmissao, nroloja)

                 if(dao.existe(notaFiscal, usuarioLogado.getNumero(),dataEmissao,dataSistema)){  
                 //Gravar o arquivo
               arquivoSelecionado.write(salvarEm + File.separator + nomeArquivo);

               //Atualiza a tela ap�s o update do controle
                dao.updateControle(notaFiscal,dataEmissao, usuarioLogado.getNumero());



               }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

           }    
           ListaAposUpdate(request, response,dataEmissao );  


        return controle;
    }
    
asked by anonymous 24.05.2018 / 06:16

0 answers