Commit 799fa838 by Yovan Martinez

Coexion entre paginas y validacion de carga de postulantes

parent bd9b5ea9
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();
}
}
...@@ -24,7 +24,7 @@ public class SaveServlet extends HttpServlet { ...@@ -24,7 +24,7 @@ public class SaveServlet extends HttpServlet {
response.setContentType("text/html"); response.setContentType("text/html");
PrintWriter out=response.getWriter(); PrintWriter out=response.getWriter();
boolean rechazarDatos = false; boolean rechazarDatos = false;
int bootcampActual = 2; int bootcampActual = Integer.parseInt(request.getParameter("bootcamp_id"));
try { try {
Connection con = DataBase.getConnection(); Connection con = DataBase.getConnection();
...@@ -116,11 +116,11 @@ public class SaveServlet extends HttpServlet { ...@@ -116,11 +116,11 @@ public class SaveServlet extends HttpServlet {
out.println("<a href=formulario.jsp >Volver al cuestionario</a>"); out.println("<a href=formulario.jsp >Volver al cuestionario</a>");
}else { }else {
out.println("<p>El correo ingresado ya esta registrado para el bootcamp actual<p>"); out.println("<p>El correo ingresado ya esta registrado para el bootcamp actual<p>");
request.getRequestDispatcher("").include(request, response); //request.getRequestDispatcher("").include(request, response);
} }
}else{ }else{
out.println("Error"); out.println("Error");
out.println("<script> window.alert('Falla al enviar la postulacion,Intente de nuevo') </script>"); //out.println("<script> window.alert('Falla al enviar la postulacion,Intente de nuevo') </script>");
} }
} }
......
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("<h1>Lista de Postulantes</h1>");
List<Postulante> list=PostulanteDao.ListarPostulantes();
out.print("<table border='1' width='100%'");
out.print("<tr><th>Id</th><th>Nombre</th><th>Apellido</th><th>Email</th><th>Direccion</th> <th>Edit</th><th>Delete</th></tr>");
for(Postulante e:list){
out.print("<tr><td>"+e.getId()+"</td><td>"+e.getNombre()+"</td><td>"+e.getApellido()+"</td> <td>"+e.getCorreo()+"</td><td>"+e.getDireccion()+"</td><td><a href='EditServlet?id="+e.getId()+"'>edit</a></td> <td><a href='DeleteServlet?id="+e.getId()+"'>delete</a></td></tr>");
}
out.print("</table>");
out.close();
}
}
<!doctype html> <%@ page language="java" contentType="text/html; charset=UTF-8"
<html lang="en"> pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,java.sql.Connection,java.sql.ResultSet,com.roshka.proyectofinal.DataBase"%>
<!doctype html>
<html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootcamp</title> <title>Bootcamp</title>
...@@ -443,10 +446,10 @@ ...@@ -443,10 +446,10 @@
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-6907191851278817" crossorigin="anonymous"></script> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-6907191851278817" crossorigin="anonymous"></script>
</head> </head>
<body> <body>
<div class="col-lg-7 mx-auto mt-5 mb-5"> <div class="col-lg-7 mx-auto mt-5 mb-5">
<h3 class="h3 mt-5">¿QUE ES UN BOOTCAMP?</h3> <h3 class="h3 mt-5">¿QUE ES UN BOOTCAMP?</h3>
...@@ -516,51 +519,37 @@ ...@@ -516,51 +519,37 @@
<div class="row"> <div class="row">
<%
Connection con = DataBase.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM bootcamp WHERE activo=true");
while(rs.next()){
%>
<div class="col-lg-7 mx-auto mb-2"> <div class="col-lg-7 mx-auto mb-2">
<div class="card card-h mb-4"> <div class="card card-h mb-4">
<img src="https://zetsan.com/wp-content/uploads/2020/10/1366_2000.jpeg" lazyload alt=" "> <img src="https://zetsan.com/wp-content/uploads/2020/10/1366_2000.jpeg" lazyload alt=<%=rs.getString( "titulo") %>>
<div class="card-body "> <div class="card-body ">
<p class="mb-1 "> BOOTCAMP JAVA </p> <p class="mb-1 ">
<p class="mb-1 "> Inicio: 18/04/2023</p> <%= rs.getString("titulo") %>
<p class="mb-1 "> Fin: 18/05/2023</p> </p>
<p class="mb-1 "> Inicio:
<%=rs.getString("fecha_inicio")%>
</p>
<p class="mb-1 "> Fin:
<%=rs.getString("fecha_fin")%>
</p>
<form action="formulario.jsp"> <form action="formulario.jsp">
<input type="submit " value="POSTULAR " /> <input name="bootcamp" type="hidden" value=<%=rs.getInt( "id") %>>
<button type="submit">POSTULAR</button>
</form> </form>
</div> </div>
</div> </div>
</div> </div>
<%
<div class="col-lg-7 mx-auto mb-2 "> }
<div class="card card-h mb-4 "> %>
<img src="https://www.pngmart.com/files/13/Android-Logo-PNG-File.png " class="card-img-top lazyload " alt="Learning Web Design: A Beginner 's Guide to HTML, CSS, JavaScript, and Web Graphics">
<div class="card-body">
<p class="mb-1"> BOOTCAMP ANDROID </p>
<p class="mb-1"> Inicio: 18/06/2023</p>
<p class="mb-1"> Fin: 18/07/2023</p>
<form action="formulario.jsp">
<input type="submit" value="POSTULAR" />
</form>
</div>
</div>
</div> </div>
</body>
<div class="col-lg-7 mx-auto mb-2">
<div class="card card-h mb-4">
<img src="https://p4.wallpaperbetter.com/wallpaper/710/859/671/technology-apple-ios-12-wallpaper-preview.jpg" lazyload " alt=" ">
<div class="card-body ">
<p class="mb-1 "> BOOTCAMP iOS </p>
<p class="mb-1 "> Inicio: 18/08/2023</p>
<p class="mb-1 "> Fin: 18/09/2023</p>
<form action="formulario.jsp ">
<input type="submit " value="POSTULAR " />
</form>
</div></div>
</div>
</div>
</body>
</div> </div>
</div> </div>
...@@ -569,4 +558,5 @@ ...@@ -569,4 +558,5 @@
</body> </body>
</html>
\ No newline at end of file </html>
\ No newline at end of file
<%@ page language="java" contentType="text/html; charset=UTF-8" <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%> pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,java.sql.Connection,java.sql.ResultSet,com.roshka.proyectofinal.DataBase,jakarta.servlet.http.HttpServlet,jakarta.servlet.http.HttpServletRequest"%>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
...@@ -11,6 +13,7 @@ pageEncoding="UTF-8"%> ...@@ -11,6 +13,7 @@ pageEncoding="UTF-8"%>
<link href="estilos/form.css" rel="stylesheet" type="text/css" /> <link href="estilos/form.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="imagenes/roshkaicon.ico" sizes="any" /> <link rel="shortcut icon" href="imagenes/roshkaicon.ico" sizes="any" />
<link rel="stylesheet" media="(max-width: 800px)" href="example.css" /> <link rel="stylesheet" media="(max-width: 800px)" href="example.css" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<title>Formulario Postulante</title> <title>Formulario Postulante</title>
</head> </head>
...@@ -24,11 +27,28 @@ pageEncoding="UTF-8"%> ...@@ -24,11 +27,28 @@ pageEncoding="UTF-8"%>
<main class="create"> <main class="create">
<article class="contenedor"> <article class="contenedor">
<div> <div>
<%
int id =Integer.parseInt(request.getParameter("bootcamp"));
System.out.print("hola"+id);
Connection con = DataBase.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM bootcamp WHERE id= "+id+ " LIMIT 1" );
rs.next();
%>
<h2>Descripcion:</h2>
<p>
<%= rs.getString("descripcion") %>
</p>
<p class="enter">Si sigues interesado y cumples con los requisitos, completa el siguiente formulario: </p> <p class="enter">Si sigues interesado y cumples con los requisitos, completa el siguiente formulario: </p>
<form method="post" action="SaveServlet" class="form"> <form method="post" action="SaveServlet" class="form">
<input type="hidden" name="bootcamp_id" value="<%= request.getParameter("bootcamp") %>">
<label for="nombre">Ingrese su Nombre:</label> <label for="nombre">Ingrese su Nombre:</label>
<input required id="nombre" name="nombre" type="text"><br> <input required id="nombre" name="nombre" type="text"><br>
...@@ -60,7 +80,7 @@ pageEncoding="UTF-8"%> ...@@ -60,7 +80,7 @@ pageEncoding="UTF-8"%>
<% while(iter.hasNext()){ <% while(iter.hasNext()){
len = iter.next(); len = iter.next();
%> %>
<li> <li class="d-flex">
<label for=<%=len.getNombre_lenguaje() %> > <%= len.getNombre_lenguaje() %> </label> <label for=<%=len.getNombre_lenguaje() %> > <%= len.getNombre_lenguaje() %> </label>
<input onclick="enviar(id)" value=<%=len.getId() %> id= <input onclick="enviar(id)" value=<%=len.getId() %> id=
<%=len.getNombre_lenguaje() %> name= <%=len.getNombre_lenguaje() %> name=
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<div class="menu"> <div class="menu">
<ul> <ul>
<li class="link-menu"><a href="">Home</a></li> <li class="link-menu"><a href="">Home</a></li>
<li class="link-menu"><a href="formulario.jsp">Postulate</a></li> <li class="link-menu"><a href="bootcamp.jsp">Postulate</a></li>
<li class="link-menu"><a href="formulario_bootcamp.jsp">Crear bootcamp</a></li> <li class="link-menu"><a href="formulario_bootcamp.jsp">Crear bootcamp</a></li>
<li class="link-menu"><a href="manage_postulantes.jsp">Manage Postulantes(perdon angel)</a></li> <li class="link-menu"><a href="manage_postulantes.jsp">Manage Postulantes(perdon angel)</a></li>
</ul> </ul>
......
...@@ -82,8 +82,7 @@ pageEncoding="UTF-8"%> ...@@ -82,8 +82,7 @@ pageEncoding="UTF-8"%>
</td> </td>
<td> <td>
<form method="post" action="EditServletPostulante"> <form method="post" action="EditServletPostulante">
<input type="hidden" value=<% %> id= <input type="hidden" value="<%=rs.getInt('id') %>">
<%=rs.getInt( "id") %>>
<% <%
String accion = ""; String accion = "";
if (rs.getBoolean("aceptado")){ if (rs.getBoolean("aceptado")){
...@@ -92,7 +91,7 @@ pageEncoding="UTF-8"%> ...@@ -92,7 +91,7 @@ pageEncoding="UTF-8"%>
accion="Aceptar"; accion="Aceptar";
} }
%> %>
<input type="submit" value=<%=accion %> <input type="submit" name="" value=<%=accion %>
<a href=""></a> <a href=""></a>
</form> </form>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment