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/src/main/java/bootcamp/BootcampDao.java b/src/main/java/bootcamp/BootcampDao.java
deleted file mode 100644
index 052cf31..0000000
--- a/src/main/java/bootcamp/BootcampDao.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package bootcamp;
-
-import 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=BootcampDao.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/bootcamp/SaveServlet.java b/src/main/java/bootcamp/SaveServlet.java
deleted file mode 100644
index 786a1b0..0000000
--- a/src/main/java/bootcamp/SaveServlet.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package bootcamp;
-
-import 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/Lenguaje.java b/src/main/java/com/roshka/proyectofinal/entity/Lenguaje.java
index 3854cb2..eb6b90a 100644
--- a/src/main/java/com/roshka/proyectofinal/entity/Lenguaje.java
+++ b/src/main/java/com/roshka/proyectofinal/entity/Lenguaje.java
@@ -8,6 +8,14 @@ public class Lenguaje {
}
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
public String getNombre_lenguaje() {
return nombre_lenguaje;
}
diff --git a/src/main/java/com/roshka/proyectofinal/lenguaje/LenguajeDao.java b/src/main/java/com/roshka/proyectofinal/lenguaje/LenguajeDao.java
index f877529..41e0335 100644
--- a/src/main/java/com/roshka/proyectofinal/lenguaje/LenguajeDao.java
+++ b/src/main/java/com/roshka/proyectofinal/lenguaje/LenguajeDao.java
@@ -5,6 +5,10 @@ import com.roshka.proyectofinal.entity.Lenguaje;
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 {
@@ -23,4 +27,24 @@ public class LenguajeDao {
return status;
}
-}
+
+ public List listar(Lenguaje l){
+ 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/entity/Bootcamp.java b/src/main/java/entity/Bootcamp.java
deleted file mode 100644
index 89deb02..0000000
--- a/src/main/java/entity/Bootcamp.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package 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/entity/Lenguaje.java b/src/main/java/entity/Lenguaje.java
deleted file mode 100644
index 2161672..0000000
--- a/src/main/java/entity/Lenguaje.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package entity;
-
-public class Lenguaje {
- private int id;
- private String nombre_lenguaje;
-
- public Lenguaje() {
-
- }
-
- 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/entity/Profesor.java b/src/main/java/entity/Profesor.java
deleted file mode 100644
index 2fc270a..0000000
--- a/src/main/java/entity/Profesor.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package 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/entity/Usuario.java b/src/main/java/entity/Usuario.java
deleted file mode 100644
index 994f47e..0000000
--- a/src/main/java/entity/Usuario.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package 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/lenguaje/LenguajeDao.java b/src/main/java/lenguaje/LenguajeDao.java
deleted file mode 100644
index 1b432c9..0000000
--- a/src/main/java/lenguaje/LenguajeDao.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package lenguaje;
-
-import entity.Lenguaje;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-
-public class LenguajeDao {
-
- public static int save(Lenguaje l){
- int status=0;
- try{
- Connection con=LenguajeDao.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;
- }
-}
diff --git a/src/main/java/lenguaje/SaveServlet.java b/src/main/java/lenguaje/SaveServlet.java
deleted file mode 100644
index 9fcd8ce..0000000
--- a/src/main/java/lenguaje/SaveServlet.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package lenguaje;
-
-import entity.Lenguaje;
-import 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_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/profesor/ProfesorDao.java b/src/main/java/profesor/ProfesorDao.java
deleted file mode 100644
index 23c0bcb..0000000
--- a/src/main/java/profesor/ProfesorDao.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package profesor;
-
-import entity.Profesor;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-
-public class ProfesorDao {
-
- public static int save(Profesor p){
- int status=0;
- try{
- Connection con=ProfesorDao.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/profesor/SaveServlet.java b/src/main/java/profesor/SaveServlet.java
deleted file mode 100644
index 1ffef7b..0000000
--- a/src/main/java/profesor/SaveServlet.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package profesor;
-
-import 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/formulario_bootcamp.jsp b/src/main/webapp/formulario_bootcamp.jsp
new file mode 100644
index 0000000..fc6b163
--- /dev/null
+++ b/src/main/webapp/formulario_bootcamp.jsp
@@ -0,0 +1,38 @@
+<%@page import="java.util.Iterator"%>
+<%@page import="lenguaje.Lenguaje"%>
+<%@page import="java.util.List"%>
+<%@page import="Lenguaje.LenguajeDao"%>
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+
+
+
+
+
+ JSP Page
+
+
+
+
Crear Bootcamp
+
+ <%
+ LenguajeDao lenguajeDao=new LenguajeDao();
+ Listlist=lenguajeDao.listar();
+ Iteratoriter=list.iterator();
+ Lenguaje len=null;
+ %>
+
+
+
+
+
+