/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { String mensaje = "se creo exitosamente el empleado"; response.sendRedirect( "vistas/crearCliente.jsp?respuesta=si&cliente=" + cliente.getNombres() + "&mensaje=" + mensaje); } finally { out.close(); } }
/** * Handles the HTTP <code>POST</code> method. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // processRequest(request, response); try { clienteDAO miCliente = new clienteDAO(); // cliente.setIdCliente(Integer.parseInt(request.getParameter("idCliente"))); cliente.setNombres(request.getParameter("nombres")); cliente.setApellidos(request.getParameter("apellidos")); cliente.setIdTipoDucomento(Integer.parseInt(request.getParameter("idTipoDocumento"))); cliente.setNumeroIdentificacion(request.getParameter("numeroIdentificacion")); cliente.setPassword(request.getParameter("password")); cliente.setCiudadResidencia(request.getParameter("ciudadResidencia")); cliente.setUltimaActualizacion(request.getParameter("ultimaActualizacion")); miCliente.guardar(cliente); processRequest(request, response); } catch (SQLException ex) { Logger.getLogger(crearEmpleadosServlet.class.getName()).log(Level.SEVERE, null, ex); } }