diff --git a/.gitignore b/.gitignore index 049313d..b3a52f7 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ target/ .settings .springBeans .sts4-cache +.hola jose ### NetBeans ### /nbproject/private/ diff --git a/.idea/encodings.xml b/.idea/encodings.xml index 63e9001..aa00ffa 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -2,5 +2,6 @@ + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 967ae10..9b4ec8b 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,12 @@ ${junit.version} test + + org.postgresql + postgresql + 42.3.5 + + diff --git a/src/main/java/com/roshka/proyectofinal/DataBase.java b/src/main/java/com/roshka/proyectofinal/DataBase.java new file mode 100644 index 0000000..12d2450 --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/DataBase.java @@ -0,0 +1,28 @@ +package com.roshka.proyectofinal; + +import java.sql.Connection; +import java.sql.DriverManager; + +public class DataBase { + + public static Connection getConnection(){ + Connection con=null; + try{ + Class.forName("org.postgresql.Driver"); + con= DriverManager + .getConnection("jdbc:postgresql://localhost:5432/bootcamp_th", + "postgres", "postgres"); + + if(con != null){ + System.out.println("---> CONNECTED TO SERVER"); + }else { + System.out.println("---> UNABLE TO CONNECTED TO SERVER"); + } + }catch(Exception e){ + e.printStackTrace(); + System.err.println(e.getClass().getName()+": "+e.getMessage()); + System.exit(0); + } + return con; + } +} diff --git a/src/main/java/com/roshka/proyectofinal/HelloServlet.java b/src/main/java/com/roshka/proyectofinal/HelloServlet.java deleted file mode 100644 index 52997b6..0000000 --- a/src/main/java/com/roshka/proyectofinal/HelloServlet.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.roshka.proyectofinal; - -import jakarta.servlet.annotation.WebServlet; -import jakarta.servlet.http.HttpServlet; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -import java.io.*; - - -@WebServlet(name = "helloServlet", value = "/hello-servlet") -public class HelloServlet extends HttpServlet { - private String message="HOLA"; - - public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { - response.setContentType("text/html"); - - // Hello - PrintWriter out = response.getWriter(); - out.println(""); - out.println("

" + message + "

"); - out.println(""); - } - - public void destroy() { - } -} \ No newline at end of file diff --git a/src/main/java/com/roshka/proyectofinal/LoginHandler.java b/src/main/java/com/roshka/proyectofinal/LoginHandler.java new file mode 100644 index 0000000..4d7999f --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/LoginHandler.java @@ -0,0 +1,52 @@ +package com.roshka.proyectofinal; + +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; + +import java.io.*; + +public class LoginHandler extends HttpServlet { + + public void doPost(HttpServletRequest req, HttpServletResponse res) + throws ServletException, IOException { + res.setContentType("text/html"); + PrintWriter out = res.getWriter(); + + // Get the user's name and password + String name = req.getParameter("name"); + String passwd = req.getParameter("passwd"); + + // Check the name and password for validity + if (!allowUser(name, passwd)) { + out.println("<HTML><HEAD><TITLE>Access Denied</TITLE></HEAD>"); + out.println("<BODY>Your login and password are invalid.<BR>"); + out.println("You may want to <A HREF=\"/login.html\">try again</A>"); + out.println("</BODY></HTML>"); + } + else { + // Valid login. Make a note in the session object. + HttpSession session = req.getSession(true); + session.putValue("logon.isDone", name); // just a marker object + + // Try redirecting the client to the page he first tried to access + try { + String target = (String) session.getValue("login.target"); + if (target != null) + res.sendRedirect(target); + return; + } + catch (Exception ignored) { } + + // Couldn't redirect to the target. Redirect to the site's home page. + res.sendRedirect(req.getScheme() + "://" + + req.getServerName() + ":" + req.getServerPort()); + } + } + + protected boolean allowUser(String user, String passwd) { + return true; // trust everyone + } +} \ No newline at end of file diff --git a/src/main/java/com/roshka/proyectofinal/Postulante/PostulanteDao.java b/src/main/java/com/roshka/proyectofinal/Postulante/PostulanteDao.java new file mode 100644 index 0000000..f820d82 --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/Postulante/PostulanteDao.java @@ -0,0 +1,33 @@ +package com.roshka.proyectofinal.Postulante; +import com.roshka.proyectofinal.DataBase; +import com.roshka.proyectofinal.entity.Postulante; + +import java.sql.Connection; +import java.sql.PreparedStatement; + +public class PostulanteDao { + + public static int save(Postulante postulante){ + int status=0; + try{ + Connection con= DataBase.getConnection(); + PreparedStatement ps=con.prepareStatement( + "insert into postulante(nombre,apellido,nro_cedula,correo,telefono,direccion,experiencia_laboral,estudio_universitario,notebook,bootcamp_id,aceptado) values (?,?,?,?,?,?,?,?,?,?,?)"); + ps.setString(1,postulante.getNombre()); + ps.setString(2,postulante.getApellido()); + ps.setInt(3,postulante.getNro_cedula()); + ps.setString(4,postulante.getCorreo()); + ps.setString(5,postulante.getTelefono()); + ps.setString(6,postulante.getDireccion()); + ps.setBoolean(7,postulante.getExpLaboral()); + ps.setBoolean(8,postulante.getEstudioUniversitario()); + ps.setBoolean(9,postulante.getNotebook()); + ps.setInt(10,postulante.getBootcampId()); + ps.setBoolean(11,postulante.getAceptado()); + status=ps.executeUpdate(); + con.close(); + }catch(Exception ex){ex.printStackTrace();} + + return status; + } +} diff --git a/src/main/java/com/roshka/proyectofinal/Postulante/PostulanteLenguajeDao.java b/src/main/java/com/roshka/proyectofinal/Postulante/PostulanteLenguajeDao.java new file mode 100644 index 0000000..39d8827 --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/Postulante/PostulanteLenguajeDao.java @@ -0,0 +1,26 @@ +package com.roshka.proyectofinal.Postulante; + +import com.roshka.proyectofinal.DataBase; +import com.roshka.proyectofinal.entity.PostulanteLenguaje; + +import java.sql.Connection; +import java.sql.PreparedStatement; + +public class PostulanteLenguajeDao { + + public static int save(PostulanteLenguaje lenguajes){ + int status=0; + try{ + Connection con= DataBase.getConnection(); + PreparedStatement ps=con.prepareStatement( + "insert into postulante_lenguaje(id_postulante,id_lenguaje) values (?,?)"); + ps.setInt(1,lenguajes.getIdPostulante()); + ps.setInt(2,lenguajes.getIdLenguaje()); + 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 new file mode 100644 index 0000000..75e1d60 --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/Postulante/SaveServlet.java @@ -0,0 +1,98 @@ +package com.roshka.proyectofinal.Postulante; + +import com.roshka.proyectofinal.DataBase; +import com.roshka.proyectofinal.entity.Postulante; +import com.roshka.proyectofinal.entity.Bootcamp; +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; + + +@WebServlet("/SaveServlet") +public class SaveServlet extends HttpServlet { + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + response.setContentType("text/html"); + PrintWriter out=response.getWriter(); + boolean rechazarDatos = false; + int bootcampActual = 3; + + try { + 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")); + String correo=request.getParameter("correo"); + //BUCLE PARA VERIFICAR EL CORREO EN EL BOOTCAMP ACTUAL + while (rs.next()){ + String correoBase =rs.getString("correo"); + int bootcampIdBase = rs.getInt("bootcamp_id"); + if(correo.equals(correoBase) && (bootcampIdBase==bootcampActual)){ + rechazarDatos = true; + } + } + String telefono=request.getParameter("telefono"); + String direccion=request.getParameter("direccion"); + boolean experienciaProgramando = false; + boolean experienciaLaboral = false; + boolean universidad = false; + boolean notebook = false; + if (request.getParameter("experiencia_laboral") != null){ + experienciaLaboral = true; + } + if (request.getParameter("experiencia_programando") != null) { + experienciaProgramando = true; + } + if (request.getParameter("notebook") != null){ + notebook = true; + } + if (request.getParameter("universidad") != null){ + universidad = true; + } + Bootcamp bootcamp = new Bootcamp(); + Postulante postulante=new Postulante(); + //SI LOS DATOS SON CORRECTOS NO SE RECHAZAN ENTONCES CARGA A LA BASE + if (!rechazarDatos){ + postulante.setNombre(nombre); + postulante.setApellido(apellido); + postulante.setNro_cedula(cedula); + postulante.setCorreo(correo); + postulante.setTelefono(telefono); + postulante.setDireccion(direccion); + postulante.setExpLaboral(experienciaLaboral); + postulante.setEstudioUniversitario(universidad); + postulante.setNotebook(notebook); + postulante.setBootcampId(bootcampActual); + postulante.setAceptado(false); + } + int status=PostulanteDao.save(postulante); + if(status>0){ + out.print("

Record saved successfully!

"); + request.getRequestDispatcher("index.html").include(request, response); + }else{ + if (rechazarDatos){ + out.println("El correo ingresado ya esta registrado para el bootcamp actual"); + }else { + out.println("Sorry! unable to save record"); + } + } + + }catch (Exception ex){ + ex.printStackTrace(); + } + out.close(); + } +} diff --git a/src/main/java/com/roshka/proyectofinal/ProtectedResource.java b/src/main/java/com/roshka/proyectofinal/ProtectedResource.java new file mode 100644 index 0000000..9c45921 --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/ProtectedResource.java @@ -0,0 +1,30 @@ +package com.roshka.proyectofinal; + +import java.io.*; +import java.util.*; +import jakarta.servlet.*; +import jakarta.servlet.http.*; + +public class ProtectedResource extends HttpServlet { + + public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + res.setContentType("text/plain"); + PrintWriter out = res.getWriter(); + + // Get the session + HttpSession session = req.getSession(true); + + // Does the session indicate this user already logged in? + Object done = session.getValue("logon.isDone"); + // marker object + if (done == null) { + // No logon.isDone means he hasn't logged in. // Save the request URL as the true target and redirect to the login page + session.putValue("login.target", + HttpUtils.getRequestURL(req).toString()); res.sendRedirect(req.getScheme() + "://" + req.getServerName() + ":" + + req.getServerPort() + "/login.html"); + return; + } + // If we get here, the user has logged in and can see the goods + out.println("Unpublished O'Reilly book manuscripts await you!"); + } + } \ No newline at end of file diff --git a/src/main/java/com/roshka/proyectofinal/bootcamp/BootcampDao.java b/src/main/java/com/roshka/proyectofinal/bootcamp/BootcampDao.java new file mode 100644 index 0000000..0edd82f --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/bootcamp/BootcampDao.java @@ -0,0 +1,36 @@ +package com.roshka.proyectofinal.bootcamp; + +import com.roshka.proyectofinal.DataBase; +import com.roshka.proyectofinal.entity.Bootcamp; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; + +public class BootcampDao { + + public static int save(Bootcamp b){ + int status=0; + + try{ + Connection con= DataBase.getConnection(); + PreparedStatement ps=con.prepareStatement( + "insert into bootcamp (id_lenguaje,id_profesor,fecha_inicio,fecha_fin,descripcion,imagen,titulo,activo) values (?,?,?,?,?,?,?,?)"); + ps.setInt(1,b.getId_lenguaje()); + ps.setInt(2,b.getId_profesor()); + ps.setString(3,b.getFecha_inicio()); + ps.setString(4,b.getFecha_fin()); + ps.setString(5,b.getDescripcion()); + ps.setString(6,b.getImagen()); + ps.setString(7,b.getTitulo()); + ps.setBoolean(8,b.getActivo()); + + status=ps.executeUpdate(); + + con.close(); + }catch(Exception ex){ex.printStackTrace();} + + return status; + } + +} diff --git a/src/main/java/com/roshka/proyectofinal/bootcamp/SaveServlet.java b/src/main/java/com/roshka/proyectofinal/bootcamp/SaveServlet.java new file mode 100644 index 0000000..d931473 --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/bootcamp/SaveServlet.java @@ -0,0 +1,45 @@ +package com.roshka.proyectofinal.bootcamp; + +import com.roshka.proyectofinal.entity.Bootcamp; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import java.io.IOException; +import java.io.PrintWriter; + +public class SaveServlet extends HttpServlet { + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html"); + PrintWriter out=response.getWriter(); + + int id_lenguaje= Integer.parseInt(request.getParameter("id_lenguaje")); + int id_profesor= Integer.parseInt(request.getParameter("id_profesor")); + String fecha_inicio=request.getParameter("fecha_inicio"); + String fecha_fin=request.getParameter("fecha_fin"); + String descripcion=request.getParameter("descripcion"); + String imagen=request.getParameter("imagen"); + String titulo=request.getParameter("titulo"); + String activoStr=request.getParameter("activo"); + Boolean activo = false; + if ( activoStr == "on" ) { + activo = true; + } + + + + Bootcamp b =new Bootcamp( id_lenguaje, id_profesor, fecha_inicio, fecha_fin, descripcion, imagen, titulo, activo); + + int status= BootcampDao.save(b); + if(status>0){ + out.print("

Record saved successfully!

"); + request.getRequestDispatcher("index.html").include(request, response); + }else{ + out.println("Sorry! unable to save record"); + } + + out.close(); + } +} diff --git a/src/main/java/com/roshka/proyectofinal/entity/Bootcamp.java b/src/main/java/com/roshka/proyectofinal/entity/Bootcamp.java new file mode 100644 index 0000000..af84e5a --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/entity/Bootcamp.java @@ -0,0 +1,92 @@ +package com.roshka.proyectofinal.entity; + +public class Bootcamp { + private int id, id_lenguaje, id_profesor; + private String fecha_inicio,fecha_fin,descripcion,imagen,titulo; + private boolean activo; + + public Bootcamp() { + + } + + public Bootcamp(int id_lenguaje, int id_profesor, String fecha_inicio, String fecha_fin, String descripcion, String imagen, String titulo, boolean activo) { + this.id_lenguaje = id_lenguaje; + this.id_profesor = id_profesor; + this.fecha_inicio = fecha_inicio; + this.fecha_fin = fecha_fin; + this.descripcion = descripcion; + this.imagen = imagen; + this.titulo = titulo; + this.activo = activo; + } + + public int getId() { + return id; + } + + public int getId_lenguaje() { + return id_lenguaje; + } + + public void setId_lenguaje(int id_lenguaje) { + this.id_lenguaje = id_lenguaje; + } + + public int getId_profesor() { + return id_profesor; + } + + public void setId_profesor(int id_profesor) { + this.id_profesor = id_profesor; + } + + public String getFecha_inicio() { + return fecha_inicio; + } + + public void setFecha_inicio(String fecha_inicio) { + this.fecha_inicio = fecha_inicio; + } + + public String getFecha_fin() { + return fecha_fin; + } + + public void setFecha_fin(String fecha_fin) { + this.fecha_fin = fecha_fin; + } + + public String getDescripcion() { + return descripcion; + } + + public void setDescripcion(String descripcion) { + this.descripcion = descripcion; + } + + public String getImagen() { + return imagen; + } + + public void setImagen(String imagen) { + this.imagen = imagen; + } + + public String getTitulo() { + return titulo; + } + + public void setTitulo(String titulo) { + this.titulo = titulo; + } + + public boolean getActivo() { + return activo; + } + + public void setActivo(boolean activo) { + this.activo = activo; + } + +} + diff --git a/src/main/java/com/roshka/proyectofinal/entity/Lenguaje.java b/src/main/java/com/roshka/proyectofinal/entity/Lenguaje.java new file mode 100644 index 0000000..eb6b90a --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/entity/Lenguaje.java @@ -0,0 +1,26 @@ +package com.roshka.proyectofinal.entity; + +public class Lenguaje { + private int id; + private String nombre_lenguaje; + + public Lenguaje() { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getNombre_lenguaje() { + return nombre_lenguaje; + } + + public void setNombre_lenguaje(String nombre_lenguaje) { + this.nombre_lenguaje = nombre_lenguaje; + } +} diff --git a/src/main/java/com/roshka/proyectofinal/entity/LoginBean.java b/src/main/java/com/roshka/proyectofinal/entity/LoginBean.java new file mode 100644 index 0000000..9b2ad7e --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/entity/LoginBean.java @@ -0,0 +1,22 @@ +package com.roshka.proyectofinal.entity; + +public class LoginBean { + private String username; + private String password; + + public String getUsername() { + return username; + } + + public String getPassword() { + return password; + } + + public void setUsername(String username) { + this.username = username; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/src/main/java/com/roshka/proyectofinal/entity/Postulante.java b/src/main/java/com/roshka/proyectofinal/entity/Postulante.java new file mode 100644 index 0000000..459696f --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/entity/Postulante.java @@ -0,0 +1,100 @@ +package com.roshka.proyectofinal.entity; + + +//Creacion del objeto Postulante +public class Postulante { + + private int id,nroCedula,bootcampId; + private String nombre,apellido,telefono,direccion,correo; + private boolean expLaboral,estudioUniversitario,notebook,aceptado; + + //Los parametros que reciban los metodos get estaran en ingles con camelCase para evitar confusiones + + + public Postulante() { + } + + public Postulante(int nroCedula, String nombre, String apellido, String telefono, String direccion, String correo, boolean expLaboral, boolean estudioUniversitario, boolean notebook, int bootcampId, boolean aceptado) { + this.nroCedula = nroCedula; + this.nombre = nombre; + this.apellido = apellido; + this.telefono = telefono; + this.direccion = direccion; + this.correo = correo; + this.expLaboral = expLaboral; + this.estudioUniversitario = estudioUniversitario; + this.notebook = notebook; + this.bootcampId = bootcampId; + this.aceptado = aceptado; + } + public int getId() { + return id; + } + public int getNro_cedula() { + return nroCedula; + } + public void setNro_cedula(int card_id) { + this.nroCedula = card_id; + } + public String getNombre() { + return nombre; + } + public void setNombre(String name) { + this.nombre = name; + } + public String getApellido() { + return apellido; + } + public void setApellido(String lastName) { + this.apellido = lastName; + } + public String getTelefono() { + return telefono; + } + public void setTelefono(String telephone) { + this.telefono = telephone; + } + public String getDireccion() { + return direccion; + } + public void setDireccion(String addres) { + this.direccion = addres; + } + public String getCorreo() { + return correo; + } + public void setCorreo(String email) { + this.correo = email; + } + public boolean getExpLaboral(){ + return expLaboral; + } + public void setExpLaboral(boolean laboralExperience){ + this.expLaboral = laboralExperience; + } + public boolean getEstudioUniversitario(){ + return estudioUniversitario; + } + public void setEstudioUniversitario(boolean university){ + this.estudioUniversitario = university; + } + public boolean getNotebook(){ + return notebook; + } + public void setNotebook(boolean notebook){ + this.notebook = notebook; + } + public boolean getAceptado(){ + return aceptado; + } + public void setAceptado(boolean acepted){ + this.aceptado = acepted; + } + public int getBootcampId(){ + return bootcampId; + } + public void setBootcampId(int bootcampId){ + this.bootcampId = bootcampId; + } + +} diff --git a/src/main/java/com/roshka/proyectofinal/entity/PostulanteLenguaje.java b/src/main/java/com/roshka/proyectofinal/entity/PostulanteLenguaje.java new file mode 100644 index 0000000..08ea525 --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/entity/PostulanteLenguaje.java @@ -0,0 +1,32 @@ +package com.roshka.proyectofinal.entity; + +public class PostulanteLenguaje { + + private int idPostulante,idLenguaje,id; + + public PostulanteLenguaje() { + } + + public PostulanteLenguaje(int idPostulante) { + this.idPostulante = idPostulante; + this.idLenguaje = idPostulante; + + } + public int getId(){ + return id; + } + public int getIdPostulante(){ + return idPostulante; + } + public void setIdPostulante(int idPostulante) { + this.idPostulante = idPostulante; + } + + public int getIdLenguaje() { + return idLenguaje; + } + + public void setIdLenguaje(int idLenguaje) { + this.idLenguaje = idLenguaje; + } +} diff --git a/src/main/java/com/roshka/proyectofinal/entity/Profesor.java b/src/main/java/com/roshka/proyectofinal/entity/Profesor.java new file mode 100644 index 0000000..94ee265 --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/entity/Profesor.java @@ -0,0 +1,49 @@ +package com.roshka.proyectofinal.entity; + +public class Profesor { + private int id,nro_cedula; + private String nombre,apellido,correo; + + public Profesor() { + + } + + public Profesor(int nro_cedula, String nombre, String apellido, String correo) { + this.nro_cedula = nro_cedula; + this.nombre = nombre; + this.apellido = apellido; + this.correo = correo; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public String getApellido() { + return apellido; + } + + public void setApellido(String apellido) { + this.apellido = apellido; + } + + public String getCorreo() { + return correo; + } + + public void setCorreo(String correo) { + this.correo = correo; + } + + public int getNro_cedula() { + return nro_cedula; + } + + public void setNro_cedula(int nro_cedula) { + this.nro_cedula = nro_cedula; + } +} diff --git a/src/main/java/com/roshka/proyectofinal/entity/Usuario.java b/src/main/java/com/roshka/proyectofinal/entity/Usuario.java new file mode 100644 index 0000000..d307639 --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/entity/Usuario.java @@ -0,0 +1,53 @@ +package com.roshka.proyectofinal.entity; + +public class Usuario { + private int id; + private String nombre,apellido,correo,contrasena; + + public Usuario() { + + } + + public Usuario(String nombre, String apellido, String correo, String contrasena) { + this.nombre = nombre; + this.apellido = apellido; + this.correo = correo; + this.contrasena = contrasena; + } + + public int getId() { + return id; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public String getApellido() { + return apellido; + } + + public void setApellido(String apellido) { + this.apellido = apellido; + } + + public String getCorreo() { + return correo; + } + + public void setCorreo(String correo) { + this.correo = correo; + } + + public String getContrasena() { + return contrasena; + } + + public void setContrasena(String contrasena) { + this.contrasena = contrasena; + } +} diff --git a/src/main/java/com/roshka/proyectofinal/lenguaje/LenguajeDao.java b/src/main/java/com/roshka/proyectofinal/lenguaje/LenguajeDao.java new file mode 100644 index 0000000..8af253f --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/lenguaje/LenguajeDao.java @@ -0,0 +1,52 @@ +package com.roshka.proyectofinal.lenguaje; + +import com.roshka.proyectofinal.DataBase; +import com.roshka.proyectofinal.entity.Lenguaje; +import jakarta.servlet.RequestDispatcher; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +public class LenguajeDao { + + public static int save(Lenguaje l){ + int status=0; + try{ + Connection con= DataBase.getConnection(); + PreparedStatement ps=con.prepareStatement( + "insert into lenguaje (nombre_lenguaje) values (?)"); + ps.setString(1,l.getNombre_lenguaje()); + + status=ps.executeUpdate(); + + con.close(); + }catch(Exception ex){ex.printStackTrace();} + + return status; + } + + public static List listar(){ + ArrayListlist = new ArrayList<>(); + String sql = "select * from lenguaje"; + try{ + Connection con= DataBase.getConnection(); + PreparedStatement ps=con.prepareStatement(sql); + ResultSet rs = ps.executeQuery(); + while(rs.next()){ + Lenguaje len = new Lenguaje(); + len.setId(rs.getInt("id")); + len.setNombre_lenguaje(rs.getString("nombre_lenguaje")); + list.add(len); + } + + con.close(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + return list; + } + } diff --git a/src/main/java/com/roshka/proyectofinal/lenguaje/ObtenerLenguaje.java b/src/main/java/com/roshka/proyectofinal/lenguaje/ObtenerLenguaje.java new file mode 100644 index 0000000..a4d20e4 --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/lenguaje/ObtenerLenguaje.java @@ -0,0 +1,24 @@ +package com.roshka.proyectofinal.lenguaje; + +import com.roshka.proyectofinal.entity.Lenguaje; +import jakarta.servlet.RequestDispatcher; +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.util.List; + +@WebServlet("/ProyectoFinal-Bootcamp/crearBootcamp") +public class ObtenerLenguaje extends HttpServlet { + + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + List len = LenguajeDao.listar(); + request.setAttribute("listaLenguaje", len); + RequestDispatcher rqd = request.getRequestDispatcher("./formulario_bootcamp.jsp"); + rqd.forward(request, response); + } +} diff --git a/src/main/java/com/roshka/proyectofinal/lenguaje/SaveServlet.java b/src/main/java/com/roshka/proyectofinal/lenguaje/SaveServlet.java new file mode 100644 index 0000000..61b907c --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/lenguaje/SaveServlet.java @@ -0,0 +1,34 @@ +package com.roshka.proyectofinal.lenguaje; + +import com.roshka.proyectofinal.entity.Lenguaje; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import java.io.IOException; +import java.io.PrintWriter; + +public class SaveServlet extends HttpServlet { + + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html"); + PrintWriter out=response.getWriter(); + + String nombre_lenguaje=request.getParameter("nombre_lenguaje"); + Lenguaje l =new Lenguaje(); + l.setNombre_lenguaje(nombre_lenguaje); + + int status=LenguajeDao.save(l); + if(status>0){ + out.print("

Record saved successfully!

"); + request.getRequestDispatcher("index.html").include(request, response); + }else{ + out.println("Sorry! unable to save record"); + } + + out.close(); + } + +} diff --git a/src/main/java/com/roshka/proyectofinal/login/LoginDao.java b/src/main/java/com/roshka/proyectofinal/login/LoginDao.java new file mode 100644 index 0000000..8ab20f8 --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/login/LoginDao.java @@ -0,0 +1,33 @@ +package com.roshka.proyectofinal.login; + +import com.roshka.proyectofinal.DataBase; +import com.roshka.proyectofinal.entity.Lenguaje; +import com.roshka.proyectofinal.entity.LoginBean; + +import java.sql.Connection; +import java.sql.PreparedStatement; + +public class LoginDao { + + public boolean validate (LoginBean loginBean) { + int status = 0; + try { + Connection con = DataBase.getConnection(); + + PreparedStatement ps=con.prepareStatement( + "select * from usuarios where username=? and password = ?"); + ps.setString(1,loginBean.getUsername()); + ps.setString(2, loginBean.getPassword()); + status=ps.executeUpdate(); + + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + + if (status > 0) return true ; + else return false ; + + } + +} diff --git a/src/main/java/com/roshka/proyectofinal/login/LoginServlet.java b/src/main/java/com/roshka/proyectofinal/login/LoginServlet.java new file mode 100644 index 0000000..c251007 --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/login/LoginServlet.java @@ -0,0 +1,61 @@ +package com.roshka.proyectofinal.login; + + +import java.io.IOException; +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 com.roshka.proyectofinal.entity.LoginBean; + +/** + * Servlet implementation class LoginServlet + */ +@WebServlet("/login") +public class LoginServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + /** + * @see HttpServlet#HttpServlet() + */ + public LoginServlet() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + response.getWriter().append("Served at: ").append(request.getContextPath()); + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + LoginDao loginDao = new LoginDao(); + + String username = request.getParameter("username"); + String password = request.getParameter("password"); + LoginBean loginBean = new LoginBean(); + loginBean.setUsername(username); + loginBean.setPassword(password); + + + if (loginDao.validate(loginBean)) + { + response.sendRedirect("loginSuccess.jsp"); + + } + else { + //HttpSession session = request.getSession(); + response.sendRedirect("login.jsp"); + + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/roshka/proyectofinal/profesor/ProfesorDao.java b/src/main/java/com/roshka/proyectofinal/profesor/ProfesorDao.java new file mode 100644 index 0000000..cdddabb --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/profesor/ProfesorDao.java @@ -0,0 +1,29 @@ +package com.roshka.proyectofinal.profesor; + +import com.roshka.proyectofinal.DataBase; +import com.roshka.proyectofinal.entity.Profesor; + +import java.sql.Connection; +import java.sql.PreparedStatement; + +public class ProfesorDao { + + public static int save(Profesor p){ + int status=0; + try{ + Connection con= DataBase.getConnection(); + PreparedStatement ps=con.prepareStatement( + "insert into profesor (nombre,apellido,nro_cedula,correo) values (?,?,?,?)"); + ps.setString(1,p.getNombre()); + ps.setString(2,p.getApellido()); + ps.setInt(3,p.getNro_cedula()); + ps.setString(4,p.getCorreo()); + + status=ps.executeUpdate(); + + con.close(); + }catch(Exception ex){ex.printStackTrace();} + + return status; + } +} diff --git a/src/main/java/com/roshka/proyectofinal/profesor/SaveServlet.java b/src/main/java/com/roshka/proyectofinal/profesor/SaveServlet.java new file mode 100644 index 0000000..526fbe4 --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/profesor/SaveServlet.java @@ -0,0 +1,36 @@ +package com.roshka.proyectofinal.profesor; + +import com.roshka.proyectofinal.entity.Profesor; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import java.io.IOException; +import java.io.PrintWriter; + +public class SaveServlet extends HttpServlet { + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html"); + PrintWriter out=response.getWriter(); + + String nombre=request.getParameter("nombre"); + String apellido=request.getParameter("apellido"); + String email=request.getParameter("correo"); + String nro_cedulaStr=request.getParameter("nro_cedula"); + int nro_cedula = Integer.parseInt(nro_cedulaStr); + Profesor p =new Profesor(nro_cedula, nombre, apellido, email); + + int status=ProfesorDao.save(p); + if(status>0){ + out.print("

Record saved successfully!

"); + request.getRequestDispatcher("index.html").include(request, response); + }else{ + out.println("Sorry! unable to save record"); + } + + out.close(); + } + +} diff --git a/src/main/webapp/Javascript.js b/src/main/webapp/Javascript.js new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/main/webapp/Javascript.js diff --git a/src/main/webapp/estilos/home.css b/src/main/webapp/estilos/home.css new file mode 100644 index 0000000..95ec9ca --- /dev/null +++ b/src/main/webapp/estilos/home.css @@ -0,0 +1,146 @@ +img.logoi{ + width: 200px; + +} + +img{ + width: 400px; + padding: 10px; + display: block; + padding:10px ; +} +.header { + margin-bottom: 0; + width: 700px; +} +a{ + float: right 100px; + color: #fff; + font-size: larger; + text-decoration: none; + padding: 10px; + +} + +body { + background: linear-gradient(100deg, rgba(20, 99, 155, 0.25), rgba(30, 148, 227, 0.25)); + background-image: url(webapp/imagenes/descarga.svg); + + background-size: contain; + background-attachment: fixed; + background-blend-mode: multiply; + font-family: Georgia, 'Times New Roman', Times, serif; + color: white; + position: relative; + width: 100px; + height: 100px; +} +/* ul{ + list-style: none; +} +.menu >ul{ + float: right; +} + +.menu li a { + + color:#fff; + text-decoration:none; + padding:10px 12px; + display:block; +} + +.menu li ul li { + marging-left + position:relative; +} */ +.menu { + width: 400%; + float: left; + + } + + .menu ul li { + float: right; + list-style-type: none; + text-align: right; + } + div.menu{ + float: right; + + + } + html, body { + margin:0; + padding:0; + height:100%; + } + + .menu ul li a { + padding-left: 5px; + + font-size: clamp(145px); + text-transform: uppercase; + display: block; + position: relative; + overflow: hidden; + padding-bottom: 50px; + white-space: nowrap; + } + .grafico,svg { + max-width: 50px; + display: block; + height: auto; +} +.seccion.hero { + margin-top: 10px; + padding-bottom: 10px; + width: 900px; +} +.hero { + perspective: 100px; +} +.hero { + display: grid; + grid-template-columns: auto repeat(5, 0.5fr) auto; +} +.hero { + display: flex; + flex-direction: column; + align-items: center; + padding-left: 200px; + /* padding-right: 200px; + */ +} +/* */ + .postulacion{ +border-radius: 30px; +} +.cta-main{ + width: 200px; + font-family: monospace; +background-color: yellow; +border: none; +} +/* Contenido pie de pagina */ +/* usamos media quiere para el responsive */ +/* @media (min-width: 768px) +.footer { + display: grid; + grid-template-rows: auto auto; + align-items: flex-start; + gap: 0; + padding: 80px 20px +} */ +.footer{ + margin-top: 10px; + padding-bottom: 10px; + height:100px; + width: 100px; + display: grid; +} + +.menu-footer a{ + text-decoration: none; + float: right; +} \ No newline at end of file diff --git a/src/main/webapp/formulario.jsp b/src/main/webapp/formulario.jsp new file mode 100644 index 0000000..787dbd1 --- /dev/null +++ b/src/main/webapp/formulario.jsp @@ -0,0 +1,92 @@ + +<%@ page language="java" contentType="text/html; charset=UTF-8" +pageEncoding="UTF-8"%> + + + + + + + JSP Page + + + +
+ +
+

Si sigues interesado y cumples con los requisitos, completa el siguiente formulario:

+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + +
+

Lenguajes de programacion que conoces:

+ + <%@ page import="com.roshka.proyectofinal.entity.Lenguaje, com.roshka.proyectofinal.lenguaje.LenguajeDao, java.util.List,java.util.Iterator" %> + + <% + LenguajeDao lenDao = new LenguajeDao(); + List listLenguaje = lenDao.listar(); + Iterator iter = listLenguaje.iterator(); + Lenguaje len = null; + + + %> +
    + <% while(iter.hasNext()){ + len = iter.next(); + + %> +
  • + id= + <%=len.getNombre_lenguaje() %> name= + <%=len.getNombre_lenguaje() %> type="checkbox">
    +
  • + + <% } %> + +
+ + +
+ + +
+ + + + +
+ +
+ + + \ No newline at end of file diff --git a/src/main/webapp/formulario_bootcamp.jsp b/src/main/webapp/formulario_bootcamp.jsp new file mode 100644 index 0000000..0061e57 --- /dev/null +++ b/src/main/webapp/formulario_bootcamp.jsp @@ -0,0 +1,40 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" +pageEncoding="UTF-8"%> + + + + + + + JSP Page + + + +
+

Crear Bootcamp

+ + <%@ page import="com.roshka.proyectofinal.entity.Lenguaje, com.roshka.proyectofinal.lenguaje.LenguajeDao, java.util.List,java.util.Iterator" %> + + <% + LenguajeDao lenDao = new LenguajeDao(); + List listLenguaje = lenDao.listar(); + Iterator iter = listLenguaje.iterator(); + Lenguaje len = null; + %> +
+ + +
+
+ + + \ No newline at end of file diff --git a/src/main/webapp/imagenes/descarga.svg b/src/main/webapp/imagenes/descarga.svg new file mode 100644 index 0000000..ee8c3f6 --- /dev/null +++ b/src/main/webapp/imagenes/descarga.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/webapp/imagenes/icon-email.svg b/src/main/webapp/imagenes/icon-email.svg new file mode 100644 index 0000000..74ce158 --- /dev/null +++ b/src/main/webapp/imagenes/icon-email.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/main/webapp/imagenes/icon-location.ico b/src/main/webapp/imagenes/icon-location.ico new file mode 100644 index 0000000..b810fe9 Binary files /dev/null and b/src/main/webapp/imagenes/icon-location.ico differ diff --git a/src/main/webapp/imagenes/icon-location.svg b/src/main/webapp/imagenes/icon-location.svg new file mode 100644 index 0000000..32ec604 --- /dev/null +++ b/src/main/webapp/imagenes/icon-location.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/main/webapp/imagenes/icon-phone.svg b/src/main/webapp/imagenes/icon-phone.svg new file mode 100644 index 0000000..e2cf3c6 --- /dev/null +++ b/src/main/webapp/imagenes/icon-phone.svg @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/imagenes/ilustracion-herov3.svg b/src/main/webapp/imagenes/ilustracion-herov3.svg new file mode 100644 index 0000000..e5d7772 --- /dev/null +++ b/src/main/webapp/imagenes/ilustracion-herov3.svg @@ -0,0 +1,288 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/imagenes/logo-roshka.svg b/src/main/webapp/imagenes/logo-roshka.svg new file mode 100644 index 0000000..db74015 --- /dev/null +++ b/src/main/webapp/imagenes/logo-roshka.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/main/webapp/imagenes/logo_footer.svg b/src/main/webapp/imagenes/logo_footer.svg new file mode 100644 index 0000000..4fa8d55 --- /dev/null +++ b/src/main/webapp/imagenes/logo_footer.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/main/webapp/imagenes/roshkaicon.ico b/src/main/webapp/imagenes/roshkaicon.ico new file mode 100644 index 0000000..234d919 Binary files /dev/null and b/src/main/webapp/imagenes/roshkaicon.ico differ diff --git a/src/main/webapp/imagenes/social-fb.svg b/src/main/webapp/imagenes/social-fb.svg new file mode 100644 index 0000000..10c1fdf --- /dev/null +++ b/src/main/webapp/imagenes/social-fb.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/main/webapp/imagenes/social-ig.svg b/src/main/webapp/imagenes/social-ig.svg new file mode 100644 index 0000000..99bee1c --- /dev/null +++ b/src/main/webapp/imagenes/social-ig.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/main/webapp/imagenes/social-linkedin.svg b/src/main/webapp/imagenes/social-linkedin.svg new file mode 100644 index 0000000..935f63b --- /dev/null +++ b/src/main/webapp/imagenes/social-linkedin.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/main/webapp/imagenes/social-twitter.svg b/src/main/webapp/imagenes/social-twitter.svg new file mode 100644 index 0000000..d7776de --- /dev/null +++ b/src/main/webapp/imagenes/social-twitter.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html new file mode 100644 index 0000000..a5665bd --- /dev/null +++ b/src/main/webapp/index.html @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + Roshka WebSite + +
+ + + +
+ + + +
+
+ + + + + + +






+
+
+
+

Es tu turno Postulate para el bootcamp

+

Aprende

+
+
+
+

Es un campo de entrenamiento intensivo y gratuito para principiantes que ya programan y quieren ser parte de la empresa

+
+
+ + +
+
+ +
+ +
+ + + +
+ + +
+ + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index dd88878..a026d71 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -1,13 +1,22 @@ +<<<<<<< HEAD +======= <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> - - - - JSP - Hello World - - -

<%= "Hello World!" %> -

-
-Hello Servlet - - \ No newline at end of file + + + + + JSP - Hello World + + + +

+ <%= "Hello World!" %> +

+
+ Hello Servlet
+ + + + + +>>>>>>> origin/develop diff --git a/src/main/webapp/login.jsp b/src/main/webapp/login.jsp new file mode 100644 index 0000000..1f1dadf --- /dev/null +++ b/src/main/webapp/login.jsp @@ -0,0 +1,21 @@ +<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + + BootcampsLogin + + +
+

User Login Form

+
+ + + + + +
User Name:
Password:
+
+
+ + + \ No newline at end of file diff --git a/src/main/webapp/loginSuccess.jsp b/src/main/webapp/loginSuccess.jsp new file mode 100644 index 0000000..2d4e892 --- /dev/null +++ b/src/main/webapp/loginSuccess.jsp @@ -0,0 +1,16 @@ +<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + + +LoginExitoso + + + +
+

LOGGIN EXITOSO

+ + +
+ + \ No newline at end of file