-3
So, I’m doing a client registration with Java web (jsp) and Servlet, where I receive in my registration database the form data and check if there is already Cpf. The code goes right down.
try {
String nome = request.getParameter("nome");
String cpf = request.getParameter("cpf");
String telefone = request.getParameter("telefone");
String email = request.getParameter("email");
String senha = request.getParameter("senha");
String cep = request.getParameter("cep");
String cidade = request.getParameter("cidade");
String uf = request.getParameter("uf");
String bairro = request.getParameter("bairro");
String endereco = request.getParameter("endereco");
String complemento = request.getParameter("complemento");
int numero = Integer.parseInt(request.getParameter("numero"));
Cliente c = new Cliente();
c.setNome(nome);
c.setCpf(cpf);
c.setTelefone(telefone);
c.setEmail(email);
c.setSenha(senha);
c.setCep(cep);
c.setCidade(cidade);
c.setUf(uf);
c.setBairro(bairro);
c.setEndereco(endereco);
c.setComplemento(complemento);
c.setNumero(numero);
ClienteDAO cDAO = new ClienteDAO();
Cliente c2 = new Cliente();
c2 = cDAO.carregaPorCpf(cpf);
if (!c.getCpf().equals(c2.getCpf())) {
cDAO.inserir(c);
response.sendRedirect("index.jsp");
} else {
out.println("<script type='text/javascript'>");
out.println("alert('CPF já cadastrado !')");
out.println("window.open('form_autocadastrar_cliente.jsp','_self')";);
out.println("</script>");
}
} catch (Exception e) {
out.print("Erro: " + e);
}
It’s working perfectly but my only problem and this out.println("window.open('form_autocadastrar_cliente.jsp','_self')";)
;
which after clicking OK, in the Alert message, refresh it on the page and reset all the form data.
It is possible to do the directing without giving refresh?
That’s not how you do it, what you did is a scam. Use the Storage location to store and rescue the registration data when needed.
– Augusto Vasques
actually worked really well and the only gambira I did there was to put link in history.back that does not need. then it got so out.println("history.back();");
– Lucas Felix