2
respostas

Duvida 6min Aula / RESOLVIDO OBRIGADO!

PROBLEMA RESOLVIDO OBRIGADO Professor poderia auxiliar por favor.. Aos 6 minutos na parte do codigo quando executo o teste o id nao esta sendo exibido no navegador nao sei o motivo.

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        System.out.println("Alterando Empresa");

        String nomeEmpresa = request.getParameter("nome");
        String paramDataEmpresa = request.getParameter("data");
        String paramId = request.getParameter("id");
        Integer id = Integer.valueOf(paramId);


        Date dataAbertura = null;
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            dataAbertura = sdf.parse(paramDataEmpresa);
        } catch (ParseException e) {
            throw new ServletException(e);
        }
        System.out.println(id);
    }
2 respostas

Oi Erick.

Pode ser que ele esteja lançando a ServletException(e). Aí ele acaba não executando do System.out.println(id).

O que ele imprime se você mudar o print de posição?

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("Alterando Empresa");

        String nomeEmpresa = request.getParameter("nome");
        String paramDataEmpresa = request.getParameter("data");
        String paramId = request.getParameter("id");
        Integer id = Integer.valueOf(paramId);
    System.out.println(id); //Nova posição do print

        Date dataAbertura = null;
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            dataAbertura = sdf.parse(paramDataEmpresa);
        } catch (ParseException e) {
            throw new ServletException(e);
        }
        //System.out.println(id);
    }

Consegui resolver Alan o problema estava no formAlteraEmpresa.jsp

Muito obrigado amigo!