Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
ProyectoFinal-Bootcamp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jose Baez
ProyectoFinal-Bootcamp
Commits
37df89f0
Commit
37df89f0
authored
May 16, 2022
by
Nahuel Mereles Rodriguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ampliando el crud a entidades lenguaje y profesor
parent
e567b940
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
310 additions
and
59 deletions
+310
-59
src/main/java/com/roshka/proyectofinal/bootcamp/BootcampDao.java
+15
-16
src/main/java/com/roshka/proyectofinal/bootcamp/DeleteServlet.java
+1
-1
src/main/java/com/roshka/proyectofinal/bootcamp/EditServlet.java
+0
-2
src/main/java/com/roshka/proyectofinal/bootcamp/SaveServlet.java
+0
-2
src/main/java/com/roshka/proyectofinal/lenguaje/DeleteServlet.java
+21
-0
src/main/java/com/roshka/proyectofinal/lenguaje/LenguajeDao.java
+34
-0
src/main/java/com/roshka/proyectofinal/lenguaje/SaveServlet.java
+3
-1
src/main/java/com/roshka/proyectofinal/profesor/DeleteServlet.java
+20
-0
src/main/java/com/roshka/proyectofinal/profesor/ProfesorDao.java
+35
-1
src/main/java/com/roshka/proyectofinal/profesor/SaveServlet.java
+3
-1
src/main/webapp/formulario_bootcamp.jsp
+1
-26
src/main/webapp/formulario_lenguaje.jsp
+76
-0
src/main/webapp/formulario_profesor.jsp
+95
-0
src/main/webapp/index.html
+6
-9
No files found.
src/main/java/com/roshka/proyectofinal/bootcamp/BootcampDao.java
View file @
37df89f0
...
...
@@ -2,7 +2,6 @@ package com.roshka.proyectofinal.bootcamp;
import
com.roshka.proyectofinal.DataBase
;
import
com.roshka.proyectofinal.entity.Bootcamp
;
import
com.roshka.proyectofinal.entity.Profesor
;
import
java.sql.*
;
import
java.util.ArrayList
;
...
...
@@ -97,6 +96,21 @@ public class BootcampDao {
return
list
;
}
public
static
int
delete
(
int
id
){
int
status
=
0
;
try
{
Connection
con
=
DataBase
.
getConnection
();
PreparedStatement
ps
=
con
.
prepareStatement
(
"delete from bootcamp where id=?"
);
ps
.
setInt
(
1
,
id
);
status
=
ps
.
executeUpdate
();
con
.
close
();
}
catch
(
Exception
e
){
e
.
printStackTrace
();}
return
status
;
}
public
static
Bootcamp
getBootcampById
(
int
id
){
Bootcamp
b
=
new
Bootcamp
();
...
...
@@ -122,19 +136,4 @@ public class BootcampDao {
return
b
;
}
public
static
int
delete
(
int
id
){
int
status
=
0
;
try
{
Connection
con
=
DataBase
.
getConnection
();
PreparedStatement
ps
=
con
.
prepareStatement
(
"delete from bootcamp where id=?"
);
ps
.
setInt
(
1
,
id
);
status
=
ps
.
executeUpdate
();
con
.
close
();
}
catch
(
Exception
e
){
e
.
printStackTrace
();}
return
status
;
}
}
src/main/java/com/roshka/proyectofinal/bootcamp/DeleteServlet.java
View file @
37df89f0
...
...
@@ -7,7 +7,7 @@ import jakarta.servlet.http.HttpServlet;
import
jakarta.servlet.http.HttpServletRequest
;
import
jakarta.servlet.http.HttpServletResponse
;
@WebServlet
(
"/DeleteServlet"
)
@WebServlet
(
"/DeleteServlet
Bootcamp
"
)
public
class
DeleteServlet
extends
HttpServlet
{
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
...
...
src/main/java/com/roshka/proyectofinal/bootcamp/EditServlet.java
View file @
37df89f0
package
com
.
roshka
.
proyectofinal
.
bootcamp
;
import
com.roshka.proyectofinal.entity.Bootcamp
;
import
jakarta.servlet.RequestDispatcher
;
import
jakarta.servlet.http.HttpServlet
;
import
jakarta.servlet.http.HttpServletRequest
;
import
jakarta.servlet.http.HttpServletResponse
;
import
jakarta.servlet.ServletException
;
import
java.io.IOException
;
import
java.util.List
;
public
class
EditServlet
extends
HttpServlet
{
...
...
src/main/java/com/roshka/proyectofinal/bootcamp/SaveServlet.java
View file @
37df89f0
...
...
@@ -28,8 +28,6 @@ public class SaveServlet extends HttpServlet {
activo
=
true
;
}
Bootcamp
b
=
new
Bootcamp
(
id_lenguaje
,
id_profesor
,
fecha_inicio
,
fecha_fin
,
descripcion
,
imagen
,
titulo
,
activo
);
int
status
=
BootcampDao
.
save
(
b
);
...
...
src/main/java/com/roshka/proyectofinal/lenguaje/DeleteServlet.java
0 → 100644
View file @
37df89f0
package
com
.
roshka
.
proyectofinal
.
lenguaje
;
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
;
@WebServlet
(
"/DeleteServletLenguaje"
)
public
class
DeleteServlet
extends
HttpServlet
{
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
String
sid
=
request
.
getParameter
(
"id"
);
int
id
=
Integer
.
parseInt
(
sid
);
System
.
out
.
println
(
"Este es el id "
+
id
);
LenguajeDao
.
delete
(
id
);
response
.
sendRedirect
(
"formulario_lenguaje.jsp"
);
}
}
src/main/java/com/roshka/proyectofinal/lenguaje/LenguajeDao.java
View file @
37df89f0
package
com
.
roshka
.
proyectofinal
.
lenguaje
;
import
com.roshka.proyectofinal.DataBase
;
import
com.roshka.proyectofinal.entity.Bootcamp
;
import
com.roshka.proyectofinal.entity.Lenguaje
;
import
jakarta.servlet.RequestDispatcher
;
...
...
@@ -50,4 +51,37 @@ public class LenguajeDao {
}
return
list
;
}
public
static
int
delete
(
int
id
){
int
status
=
0
;
try
{
Connection
con
=
DataBase
.
getConnection
();
PreparedStatement
ps
=
con
.
prepareStatement
(
"delete from lenguaje where id=?"
);
ps
.
setInt
(
1
,
id
);
status
=
ps
.
executeUpdate
();
con
.
close
();
}
catch
(
Exception
e
){
e
.
printStackTrace
();}
return
status
;
}
public
static
Lenguaje
getLenguajeById
(
int
id
){
Lenguaje
lenguaje
=
new
Lenguaje
();
try
{
Connection
con
=
DataBase
.
getConnection
();
PreparedStatement
ps
=
con
.
prepareStatement
(
"select * from lenguaje where id=?"
);
ps
.
setInt
(
1
,
id
);
ResultSet
rs
=
ps
.
executeQuery
();
if
(
rs
.
next
()){
lenguaje
.
setId
(
rs
.
getInt
(
"id"
));
lenguaje
.
setNombre_lenguaje
(
rs
.
getString
(
"nombre_lenguaje"
));
}
con
.
close
();
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();}
return
lenguaje
;
}
}
src/main/java/com/roshka/proyectofinal/lenguaje/SaveServlet.java
View file @
37df89f0
...
...
@@ -2,6 +2,7 @@ package com.roshka.proyectofinal.lenguaje;
import
com.roshka.proyectofinal.entity.Lenguaje
;
import
jakarta.servlet.ServletException
;
import
jakarta.servlet.annotation.WebServlet
;
import
jakarta.servlet.http.HttpServlet
;
import
jakarta.servlet.http.HttpServletRequest
;
import
jakarta.servlet.http.HttpServletResponse
;
...
...
@@ -9,6 +10,7 @@ import jakarta.servlet.http.HttpServletResponse;
import
java.io.IOException
;
import
java.io.PrintWriter
;
@WebServlet
(
"/SaveServletLenguaje"
)
public
class
SaveServlet
extends
HttpServlet
{
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
...
...
@@ -23,7 +25,7 @@ public class SaveServlet extends HttpServlet {
int
status
=
LenguajeDao
.
save
(
l
);
if
(
status
>
0
){
out
.
print
(
"<p>Record saved successfully!</p>"
);
request
.
getRequestDispatcher
(
"
index.html
"
).
include
(
request
,
response
);
request
.
getRequestDispatcher
(
"
formulario_lenguaje.jsp
"
).
include
(
request
,
response
);
}
else
{
out
.
println
(
"Sorry! unable to save record"
);
}
...
...
src/main/java/com/roshka/proyectofinal/profesor/DeleteServlet.java
0 → 100644
View file @
37df89f0
package
com
.
roshka
.
proyectofinal
.
profesor
;
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
;
@WebServlet
(
"/DeleteServletProfesor"
)
public
class
DeleteServlet
extends
HttpServlet
{
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
String
sid
=
request
.
getParameter
(
"id"
);
int
id
=
Integer
.
parseInt
(
sid
);
ProfesorDao
.
delete
(
id
);
response
.
sendRedirect
(
"formulario_profesor.jsp"
);
}
}
src/main/java/com/roshka/proyectofinal/profesor/ProfesorDao.java
View file @
37df89f0
package
com
.
roshka
.
proyectofinal
.
profesor
;
import
com.roshka.proyectofinal.DataBase
;
import
com.roshka.proyectofinal.entity.Bootcamp
;
import
com.roshka.proyectofinal.entity.Profesor
;
import
java.sql.Connection
;
...
...
@@ -59,4 +58,39 @@ public class ProfesorDao {
}
return
list
;
}
public
static
int
delete
(
int
id
){
int
status
=
0
;
try
{
Connection
con
=
DataBase
.
getConnection
();
PreparedStatement
ps
=
con
.
prepareStatement
(
"delete from profesor where id=?"
);
ps
.
setInt
(
1
,
id
);
status
=
ps
.
executeUpdate
();
con
.
close
();
}
catch
(
Exception
e
){
e
.
printStackTrace
();}
return
status
;
}
public
static
Profesor
getProfesorById
(
int
id
){
Profesor
p
=
new
Profesor
();
try
{
Connection
con
=
DataBase
.
getConnection
();
PreparedStatement
ps
=
con
.
prepareStatement
(
"select * from profesor where id=?"
);
ps
.
setInt
(
1
,
id
);
ResultSet
rs
=
ps
.
executeQuery
();
if
(
rs
.
next
()){
p
.
setId
(
rs
.
getInt
(
"id"
));
p
.
setNombre
(
rs
.
getString
(
"nombre"
));
p
.
setApellido
(
rs
.
getString
(
"apellido"
));
p
.
setNro_cedula
(
rs
.
getInt
(
"nro_cedula"
));
p
.
setCorreo
(
rs
.
getString
(
"correo"
));
}
con
.
close
();
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();}
return
p
;
}
}
src/main/java/com/roshka/proyectofinal/profesor/SaveServlet.java
View file @
37df89f0
...
...
@@ -2,6 +2,7 @@ package com.roshka.proyectofinal.profesor;
import
com.roshka.proyectofinal.entity.Profesor
;
import
jakarta.servlet.ServletException
;
import
jakarta.servlet.annotation.WebServlet
;
import
jakarta.servlet.http.HttpServlet
;
import
jakarta.servlet.http.HttpServletRequest
;
import
jakarta.servlet.http.HttpServletResponse
;
...
...
@@ -9,6 +10,7 @@ import jakarta.servlet.http.HttpServletResponse;
import
java.io.IOException
;
import
java.io.PrintWriter
;
@WebServlet
(
"/SaveServletProfesor"
)
public
class
SaveServlet
extends
HttpServlet
{
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
...
...
@@ -25,7 +27,7 @@ public class SaveServlet extends HttpServlet {
int
status
=
ProfesorDao
.
save
(
p
);
if
(
status
>
0
){
out
.
print
(
"<p>Record saved successfully!</p>"
);
request
.
getRequestDispatcher
(
"
index.html
"
).
include
(
request
,
response
);
request
.
getRequestDispatcher
(
"
formulario_profesor.jsp
"
).
include
(
request
,
response
);
}
else
{
out
.
println
(
"Sorry! unable to save record"
);
}
...
...
src/main/webapp/formulario_bootcamp.jsp
View file @
37df89f0
...
...
@@ -19,16 +19,12 @@
LenguajeDao
lenDao =
new
LenguajeDao
();
List
<
Lenguaje
>
listLenguaje = lenDao.listar();
Iterator
<Lenguaje>
iter = listLenguaje.iterator();
<
<<<<<<
HEAD
Lenguaje len = null;
ProfesorDao profeDao = new ProfesorDao();
List
<Profesor>
listProfesor = profeDao.listar();
Iterator
<Profesor>
iterProfe = listProfesor.iterator();
Profesor profe = null;
=======
Lenguaje len = null;
>>>>>>> develop
%>
<form
action=
""
method=
"post"
>
<label
for=
"lenguaje"
>
Lenguajes:
</label>
...
...
@@ -42,7 +38,6 @@
</option>
<
%
}
%
>
</select>
<
<<<<<<
HEAD
<label
for=
"lenguaje"
>
Profesores:
</label>
<select
name=
"lenguaje"
id=
"lenguaje"
>
...
...
@@ -56,25 +51,7 @@
<
%
}
%
>
</select>
</form>
<
%=
Bootcamp
editBootcampList =
(Bootcamp)request.getAttribute("id");
if
(
editBootcampList
)
{
<
form
action=
""
method=
"post"
>
<label
for=
"titulo"
>
titulo:
</label>
<input
type=
"text"
name=
"titulo"
id=
"titulo"
value=
<%=
editBootcampList
.
getTitulo
()
%
>
>
<label
for=
"descripcion"
>
descripcion:
</label>
<input
type=
"text"
name=
"descripcion"
id=
"descripcion"
value=
<%=
editBootcampList
.
getDescripcion
()
%
>
>
<label
for=
"fecha_inicio"
>
fecha de inicio:
</label>
<input
type=
"text"
name=
"fecha_inicio"
id=
"fecha_inicio"
value=
<%=
editBootcampList
.
getFecha_inicio
()
%
>
>
<label
for=
"fecha_fin"
>
fecha de fin:
</label>
<input
type=
"text"
name=
"fecha_fin"
id=
"fecha_fin"
value=
<%=
editBootcampList
.
getFecha_inicio
()
%
>
>
<label
for=
"profesor"
>
profesor:
</label>
<input
type=
"text"
name=
"profesor"
id=
"profesor"
value=
<%=
editBootcampList
.
getNombre_profesor
()
%
>
>
<label
for=
"lenguaje"
>
lenguaje
</label>
<input
type=
"text"
name=
"lenguaje"
id=
"lenguaje"
>
</form>
}%>
</div>
...
...
@@ -116,7 +93,7 @@
</form>
</th>
<th>
<form
action=
"DeleteServlet"
method=
"get"
>
<form
action=
"DeleteServlet
Bootcamp
"
method=
"get"
>
<input
type=
"hidden"
name=
"id"
value=
<%=
boot
.
getId
()
%
>
>
<input
type=
"submit"
value=
"Borrar"
>
</input>
</form>
...
...
@@ -125,9 +102,7 @@
<
%
}
%
>
</tbody>
</table>
=======
</form>
>>>>>>> develop
</div>
</body>
...
...
src/main/webapp/formulario_lenguaje.jsp
0 → 100644
View file @
37df89f0
<
%@
page
contentType=
"text/html;charset=UTF-8"
language=
"java"
%
>
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=UTF-8"
>
<link
href=
"css/bootstrap.css"
rel=
"stylesheet"
type=
"text/css"
/>
<title>
JSP Page
</title>
</head>
<body>
<div>
<h1>
Crear Lenguaje
</h1>
<
%@
page
import=
"com.roshka.proyectofinal.entity.Lenguaje, com.roshka.proyectofinal.lenguaje.LenguajeDao, java.util.List,java.util.Iterator"
%
>
</div>
<div>
<
%
LenguajeDao
lenDao =
new
LenguajeDao
();
List
<
Lenguaje
>
listLen = lenDao.listar();
Iterator
<Lenguaje>
iterLen = listLen.iterator();
Lenguaje lenguaje = null;
%>
<form
method=
"post"
action=
"SaveServletLenguaje"
>
<label
for=
"nombre_lenguaje"
>
Nombre del Lenguaje nuevo:
</label>
<input
name=
"nombre_lenguaje"
>
</input>
<button
type=
"submit"
>
Crear Lenguaje
</button>
</form>
<table>
<thead>
<tr>
<th>
Lenguaje
</th>
<th>
Editar
</th>
<th>
Eliminar
</th>
</tr>
</thead>
<tbody>
<
%
while
(
iterLen
.
hasNext
()){
lenguaje =
iterLen.next();
%
>
<th>
<
%=
lenguaje
.
getNombre_lenguaje
()
%
>
</th>
<th>
<form
action=
"EditServlet"
method=
"get"
>
<input
type=
"hidden"
name=
"id"
value=
<%=
lenguaje
.
getId
()
%
>
>
<input
type=
"submit"
value=
"Editar"
>
</input>
</form>
</th>
<th>
<form
action=
"DeleteServletLenguaje"
method=
"get"
>
<input
type=
"hidden"
name=
"id"
value=
<%=
lenguaje
.
getId
()
%
>
>
<input
type=
"submit"
value=
"Borrar"
>
</input>
</form>
</th>
</tr>
<
%
}
%
>
</tbody>
</table>
</form>
</div>
</body>
</html>
\ No newline at end of file
src/main/webapp/formulario_profesor.jsp
0 → 100644
View file @
37df89f0
<
%@
page
contentType=
"text/html;charset=UTF-8"
language=
"java"
%
>
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=UTF-8"
>
<link
href=
"css/bootstrap.css"
rel=
"stylesheet"
type=
"text/css"
/>
<title>
JSP Page
</title>
</head>
<body>
<div>
<h1>
Crear Profesor
</h1>
<
%@
page
import=
"com.roshka.proyectofinal.entity.Profesor, com.roshka.proyectofinal.profesor.ProfesorDao, java.util.List,java.util.Iterator"
%
>
</div>
<div>
<
%
ProfesorDao
profeDao =
new
ProfesorDao
();
List
<
Profesor
>
listProfe = profeDao.listar();
Iterator
<Profesor>
iterProfe = listProfe.iterator();
Profesor profesor = null;
%>
<form
method=
"post"
action=
"SaveServletProfesor"
>
<label
for=
"nombre"
>
Nombre:
</label>
<input
name=
"nombre"
></input>
<label
for=
"apellido"
>
Apellido:
</label>
<input
name=
"apellido"
></input>
<label
for=
"correo"
>
Correo:
</label>
<input
name=
"correo"
></input>
<label
for=
"nro_cedula"
>
Numero de Cedula:
</label>
<input
name=
"nro_cedula"
></input>
<button
type=
"submit"
>
Crear Profesor
</button>
</form>
<table>
<thead>
<tr>
<th>
Nombre
</th>
<th>
Apellido
</th>
<th>
Numero de Cedula
</th>
<th>
Correo
</th>
<th>
Editar
</th>
<th>
Eliminar
</th>
</tr>
</thead>
<tbody>
<
%
while
(
iterProfe
.
hasNext
()){
profesor =
iterProfe.next();
%
>
<th>
<
%=
profesor
.
getNombre
()
%
>
</th>
<th>
<
%=
profesor
.
getApellido
()
%
>
</th>
<th>
<
%=
profesor
.
getNro_cedula
()
%
>
</th>
<th>
<
%=
profesor
.
getCorreo
()
%
>
</th>
<th>
<form
action=
"EditServlet"
method=
"get"
>
<input
type=
"hidden"
name=
"id"
value=
<%=
profesor
.
getId
()
%
>
>
<input
type=
"submit"
value=
"Editar"
>
</input>
</form>
</th>
<th>
<form
action=
"DeleteServletProfesor"
method=
"get"
>
<input
type=
"hidden"
name=
"id"
value=
<%=
profesor
.
getId
()
%
>
>
<input
type=
"submit"
value=
"Borrar"
></input>
</form>
</th>
</tr>
<
%
}
%
>
</tbody>
</table>
</form>
</div>
</body>
</html>
\ No newline at end of file
src/main/webapp/index.html
View file @
37df89f0
...
...
@@ -22,21 +22,18 @@
<!-- logo con link -->
</div>
<div
class=
"menu"
>
<
<<<<<<
HEAD
<
ul
>
<li
class=
"link-menu"
><a
href=
""
>
Home
</a></li>
<li
class=
"link-menu"
><a
href=
"formulario.html"
>
Postulate
</a></li>
<li
class=
"link-menu"
><a
href=
"formulario_bootcamp.jsp"
>
Crear bootcamp
</a>
</li>
</ul>
=======
<ul>
<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=
"formulario_bootcamp.jsp"
>
Crear bootcamp
</a>
</li>
<li
class=
"link-menu"
><a
href=
"formulario_lenguaje.jsp"
>
Crear lenguaje
</a>
</li>
<li
class=
"link-menu"
><a
href=
"formulario_profesor.jsp"
>
Crear profesor
</a>
</li>
</ul>
>>>>>>> develop
</div>
<!-- menu -->
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment