use of br.senac.tads3.pi03b.gruposete.dao.UsuarioDAO in project Loja_Agencia_De_Viagens by ArtCouSan.
the class ExcluiUsuarioServlet method doGet.
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String action = request.getParameter("action");
String pesquisa = request.getParameter("pesquisa");
UsuarioDAO query = new UsuarioDAO();
if ("edit".equalsIgnoreCase(action)) {
int id = Integer.parseInt(request.getParameter("id"));
try {
query.excluirUsuario(id);
List<Usuario> encontrados = query.procurarUsuario(pesquisa);
request.setAttribute("encontrados", encontrados);
} catch (SQLException | ClassNotFoundException ex) {
Logger.getLogger(ExcluiClienteServlet.class.getName()).log(Level.SEVERE, null, ex);
} catch (Exception ex) {
Logger.getLogger(ExcluiUsuarioServlet.class.getName()).log(Level.SEVERE, null, ex);
}
RequestDispatcher dispatcher = request.getRequestDispatcher("/jsp/Listar/ListaUsuario.jsp");
dispatcher.forward(request, response);
}
}
use of br.senac.tads3.pi03b.gruposete.dao.UsuarioDAO in project Loja_Agencia_De_Viagens by ArtCouSan.
the class CadastroUsuarioServlet method doPost.
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
UsuarioDAO dao = new UsuarioDAO();
boolean erro = false;
String nome = request.getParameter("nome");
if (nome == null || nome.length() < 1) {
erro = true;
request.setAttribute("erroNome", true);
}
String login = request.getParameter("login");
if (login == null || login.length() < 1) {
erro = true;
request.setAttribute("erroLogin", true);
}
String senha = request.getParameter("senha");
if (senha == null || senha.length() < 4) {
erro = true;
request.setAttribute("erroSenha", true);
}
String acesso = request.getParameter("acesso");
if (acesso == null || acesso.length() < 1) {
erro = true;
request.setAttribute("erroAcesso", true);
}
if (!erro) {
Usuario usuarioHumilde = new Usuario(nome, login, senha, acesso);
try {
dao.inserir(usuarioHumilde);
HttpSession sessao = request.getSession();
sessao.setAttribute("novoUsuario", usuarioHumilde);
response.sendRedirect("index.jsp");
} catch (Exception ex) {
Logger.getLogger(CadastroUsuarioServlet.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
RequestDispatcher dispatcher = request.getRequestDispatcher("/jsp/Cadastrar/CadastroUsuario.jsp");
dispatcher.forward(request, response);
}
}
Aggregations