From d3c627c3330e7f1872bfbb979cfa801016343f5a Mon Sep 17 00:00:00 2001
From: Yovan Martinez
Date: Sun, 15 May 2022 22:00:10 -0400
Subject: [PATCH] Terminado validacion al enviar formulario y creacion de manage_postulante para aceptar o rechazr los mismos
---
src/main/java/com/roshka/proyectofinal/DataBase.java | 2 +-
src/main/java/com/roshka/proyectofinal/Postulante/EditServletPostulante.java | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
src/main/java/com/roshka/proyectofinal/Postulante/PostulanteDao.java | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
src/main/java/com/roshka/proyectofinal/Postulante/SaveServlet.java | 10 +++++++---
src/main/java/com/roshka/proyectofinal/Postulante/ViewServletPostulantes.java | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/main/java/com/roshka/proyectofinal/entity/Postulante.java | 5 +++++
src/main/webapp/Javascript.js | 5 ++---
src/main/webapp/bootcamp.html | 62 ++++++++++++++++++++++++++++++++------------------------------
src/main/webapp/formulario.jsp | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------
src/main/webapp/index.html | 6 +++---
src/main/webapp/index.jsp | 5 +----
src/main/webapp/manage_bootcamp.html | 15 ---------------
12 files changed, 351 insertions(+), 156 deletions(-)
create mode 100644 src/main/java/com/roshka/proyectofinal/Postulante/EditServletPostulante.java
create mode 100644 src/main/java/com/roshka/proyectofinal/Postulante/ViewServletPostulantes.java
delete mode 100644 src/main/webapp/manage_bootcamp.html
diff --git a/src/main/java/com/roshka/proyectofinal/DataBase.java b/src/main/java/com/roshka/proyectofinal/DataBase.java
index 12d2450..49e9a55 100644
--- a/src/main/java/com/roshka/proyectofinal/DataBase.java
+++ b/src/main/java/com/roshka/proyectofinal/DataBase.java
@@ -10,7 +10,7 @@ public class DataBase {
try{
Class.forName("org.postgresql.Driver");
con= DriverManager
- .getConnection("jdbc:postgresql://localhost:5432/bootcamp_th",
+ .getConnection("jdbc:postgresql://localhost:5433/bootcamp_th",
"postgres", "postgres");
if(con != null){
diff --git a/src/main/java/com/roshka/proyectofinal/Postulante/EditServletPostulante.java b/src/main/java/com/roshka/proyectofinal/Postulante/EditServletPostulante.java
new file mode 100644
index 0000000..2eb5167
--- /dev/null
+++ b/src/main/java/com/roshka/proyectofinal/Postulante/EditServletPostulante.java
@@ -0,0 +1,49 @@
+package com.roshka.proyectofinal.Postulante;
+
+import com.roshka.proyectofinal.DataBase;
+import com.roshka.proyectofinal.entity.Postulante;
+import com.roshka.proyectofinal.entity.Bootcamp;
+import com.roshka.proyectofinal.entity.PostulanteLenguaje;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.annotation.WebServlet;
+import jakarta.servlet.http.HttpServlet;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import javafx.geometry.Pos;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.*;
+import java.util.List;
+
+@WebServlet("/EditServletPostulante")
+ public class EditServletPostulante extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html");
+ PrintWriter out = response.getWriter();
+
+ String sid = request.getParameter("id");
+ boolean accion;
+ if (request.getParameter("value") == "Rechazar") {
+ accion = false;
+ } else {
+ accion = true;
+ }
+ int id = Integer.parseInt(sid);
+ Postulante e = new Postulante();
+ e.setId(id);
+ e.setAceptado(accion);
+
+
+ int status = PostulanteDao.update(e);
+ if (status > 0) {
+ response.sendRedirect("ViewServlet");
+ } else {
+ out.println("Sorry! unable to update record");
+ }
+
+ out.close();
+ }
+ }
+
diff --git a/src/main/java/com/roshka/proyectofinal/Postulante/PostulanteDao.java b/src/main/java/com/roshka/proyectofinal/Postulante/PostulanteDao.java
index f820d82..1d69e58 100644
--- a/src/main/java/com/roshka/proyectofinal/Postulante/PostulanteDao.java
+++ b/src/main/java/com/roshka/proyectofinal/Postulante/PostulanteDao.java
@@ -1,11 +1,17 @@
package com.roshka.proyectofinal.Postulante;
import com.roshka.proyectofinal.DataBase;
import com.roshka.proyectofinal.entity.Postulante;
+import jakarta.servlet.http.HttpServlet;
+import javafx.geometry.Pos;
+import javax.xml.crypto.Data;
import java.sql.Connection;
import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.List;
-public class PostulanteDao {
+public class PostulanteDao extends HttpServlet {
public static int save(Postulante postulante){
int status=0;
@@ -30,4 +36,48 @@ public class PostulanteDao {
return status;
}
+ public static List ListarPostulantes(){
+ List list=new ArrayList();
+
+
+ try{
+
+ Connection con= DataBase.getConnection();
+ PreparedStatement ps=con.prepareStatement("select * from postulante");
+ ResultSet rs=ps.executeQuery();
+ while(rs.next()){
+ Postulante e=new Postulante();
+
+ e.setId(rs.getInt("id"));
+ e.setNombre(rs.getString("nombre"));
+ //e.setPassword(rs.getString(3));
+ e.setCorreo(rs.getString("correo"));
+ e.setApellido(rs.getString("apellido"));
+ e.setDireccion(rs.getString("direccion"));
+ list.add(e);
+ }
+ con.close();
+ }catch(Exception e){e.printStackTrace();}
+
+ return list;
+ }
+ public static int update (Postulante e){
+ int status=0;
+ try{
+ Connection con= DataBase.getConnection();
+ PreparedStatement ps=con.prepareStatement(
+ "update postulante set aceptado=? where id=?");
+ ps.setBoolean(1,e.getAceptado());
+ ps.setInt(2,e.getId());
+ status=ps.executeUpdate();
+ con.close();
+ }catch(Exception ex){ex.printStackTrace();}
+
+ return status;
+ }
+
+
+
+
}
+
diff --git a/src/main/java/com/roshka/proyectofinal/Postulante/SaveServlet.java b/src/main/java/com/roshka/proyectofinal/Postulante/SaveServlet.java
index 1f70deb..5201c6a 100644
--- a/src/main/java/com/roshka/proyectofinal/Postulante/SaveServlet.java
+++ b/src/main/java/com/roshka/proyectofinal/Postulante/SaveServlet.java
@@ -30,6 +30,7 @@ public class SaveServlet extends HttpServlet {
Connection con = DataBase.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT correo,bootcamp_id FROM postulante WHERE postulante.bootcamp_id =" + bootcampActual);
+
String nombre=request.getParameter("nombre");
String apellido=request.getParameter("apellido");
int cedula=Integer.parseInt(request.getParameter("cedula"));
@@ -105,18 +106,21 @@ public class SaveServlet extends HttpServlet {
}
}
if(status >0 && statusLenguaje > 0){
+ //out.println("");
out.print("Record saved successfully!
");
- request.getRequestDispatcher("index.html").include(request, response);
+ request.getRequestDispatcher("formulario.jsp").include(request, response);
}else{
if (rechazarDatos){
if (contador == 0){
out.println("Debe seleccionar al menos una opcion de lenguaje que conoce para postularse");
out.println("Volver al cuestionario ");
}else {
- out.println("El correo ingresado ya esta registrado para el bootcamp actual");
+ out.println("El correo ingresado ya esta registrado para el bootcamp actual
");
+ request.getRequestDispatcher("").include(request, response);
}
}else{
- out.println("Sorry! unable to save record");
+ out.println("Error");
+ out.println("");
}
}
diff --git a/src/main/java/com/roshka/proyectofinal/Postulante/ViewServletPostulantes.java b/src/main/java/com/roshka/proyectofinal/Postulante/ViewServletPostulantes.java
new file mode 100644
index 0000000..84bc05c
--- /dev/null
+++ b/src/main/java/com/roshka/proyectofinal/Postulante/ViewServletPostulantes.java
@@ -0,0 +1,60 @@
+package com.roshka.proyectofinal.Postulante;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.List;
+
+import com.roshka.proyectofinal.DataBase;
+import com.roshka.proyectofinal.entity.Postulante;
+import com.roshka.proyectofinal.entity.Bootcamp;
+import com.roshka.proyectofinal.entity.PostulanteLenguaje;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.annotation.WebServlet;
+import jakarta.servlet.http.HttpServlet;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import javafx.geometry.Pos;
+import com.roshka.proyectofinal.DataBase;
+import com.roshka.proyectofinal.entity.Postulante;
+import com.roshka.proyectofinal.entity.Bootcamp;
+import com.roshka.proyectofinal.entity.PostulanteLenguaje;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.annotation.WebServlet;
+import jakarta.servlet.http.HttpServlet;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.*;
+import java.util.List;
+@WebServlet("/ViewServletPostulante")
+public class ViewServletPostulantes extends HttpServlet{
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html");
+ PrintWriter out=response.getWriter();
+ out.println("
Lista de Postulantes ");
+
+ List list=PostulanteDao.ListarPostulantes();
+
+ out.print("Id Nombre Apellido Email Direccion Edit Delete ");
+ for(Postulante e:list){
+ out.print(""+e.getId()+" "+e.getNombre()+" "+e.getApellido()+" "+e.getCorreo()+" "+e.getDireccion()+" edit delete ");
+ }
+ out.print("
");
+
+ out.close();
+ }
+}
+
+
+
+
+
diff --git a/src/main/java/com/roshka/proyectofinal/entity/Postulante.java b/src/main/java/com/roshka/proyectofinal/entity/Postulante.java
index 459696f..3efe249 100644
--- a/src/main/java/com/roshka/proyectofinal/entity/Postulante.java
+++ b/src/main/java/com/roshka/proyectofinal/entity/Postulante.java
@@ -30,6 +30,11 @@ public class Postulante {
public int getId() {
return id;
}
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
public int getNro_cedula() {
return nroCedula;
}
diff --git a/src/main/webapp/Javascript.js b/src/main/webapp/Javascript.js
index b125cd2..b40dba6 100644
--- a/src/main/webapp/Javascript.js
+++ b/src/main/webapp/Javascript.js
@@ -1,5 +1,5 @@
(function() {
- const form = document.querySelector('#sectionForm');
+ const form = document.querySelector('#agarraunolaputa');
const checkboxes = form.querySelectorAll('input[type=checkbox]');
const checkboxLength = checkboxes.length;
const firstCheckbox = checkboxLength > 0 ? checkboxes[0] : null;
@@ -22,9 +22,8 @@
}
function checkValidity() {
- const errorMessage = !isChecked() ? 'Debe de selecionar al menos un lenguaje' : '';
+ const errorMessage = !isChecked() ? 'Debe seleccionar al menos un lenguaje que conozca' : '';
firstCheckbox.setCustomValidity(errorMessage);
}
-
init();
})();
\ No newline at end of file
diff --git a/src/main/webapp/bootcamp.html b/src/main/webapp/bootcamp.html
index 0d08989..5910df2 100644
--- a/src/main/webapp/bootcamp.html
+++ b/src/main/webapp/bootcamp.html
@@ -521,42 +521,44 @@
-
+
+
+
BOOTCAMP JAVA
+
Inicio: 18/04/2023
+
Fin: 18/05/2023
+
+
+
+
+
+
+
+
+
+
BOOTCAMP ANDROID
+
Inicio: 18/06/2023
+
Fin: 18/07/2023
+
+
+
+
+
+
+
+
-
BOOTCAMP JAVA
-
Inicio: 18/04/2023
-
Fin: 18/05/2023
+
BOOTCAMP iOS
+
Inicio: 18/08/2023
+
Fin: 18/09/2023
-
-
-
-
-
-
BOOTCAMP ANDROID
-
Inicio: 18/06/2023
-
Fin: 18/07/2023
-
-
-
-
-
-
-
-
-
BOOTCAMP iOS
-
Inicio: 18/08/2023
-
Fin: 18/09/2023
-
-
-
-
-
-
-
-
-
-
-
-
Si sigues interesado y cumples con los requisitos, completa el siguiente formulario:
-
-
diff --git a/src/main/webapp/formulario.jsp b/src/main/webapp/formulario.jsp
index a5ea3e1..7b35070 100644
--- a/src/main/webapp/formulario.jsp
+++ b/src/main/webapp/formulario.jsp
@@ -1,134 +1,168 @@
-<<<<<<< HEAD=======>>>>>>> 83a3c531a8a7130549d357f69034fe5d79ee8984
- <%@ page language="java" contentType="text/html; charset=UTF-8"
+<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
-
-
-
-
-
- <<<<<<< HEAD
-
-
JSP Page
- =======
-
-
-
-
Formulario Postulante
- >>>>>>> 83a3c531a8a7130549d357f69034fe5d79ee8984
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html
index abe047c..25c514e 100644
--- a/src/main/webapp/index.html
+++ b/src/main/webapp/index.html
@@ -24,9 +24,9 @@
diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp
index a026d71..10d3215 100644
--- a/src/main/webapp/index.jsp
+++ b/src/main/webapp/index.jsp
@@ -1,5 +1,3 @@
-<<<<<<< HEAD
-=======
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
@@ -18,5 +16,4 @@
-