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
0ff36db1
Commit
0ff36db1
authored
2 years ago
by
Rebecca Arzamendia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filtro de profesor
parent
22f3b1f0
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
148 additions
and
64 deletions
+148
-64
.idea/misc.xml
+2
-1
src/main/java/com/roshka/proyectofinal/profesor/EditServlet.java
+8
-8
src/main/java/com/roshka/proyectofinal/profesor/Filtros.java
+46
-0
src/main/java/com/roshka/proyectofinal/profesor/ProfesorDao.java
+28
-52
src/main/webapp/formulario_profesor.jsp
+11
-2
src/main/webapp/postulante-consulta.jsp
+1
-1
src/main/webapp/profesor-consulta.jsp
+52
-0
No files found.
.idea/misc.xml
View file @
0ff36db1
...
...
@@ -10,7 +10,7 @@
</list>
</option>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1
7
"
default=
"true"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1
_8
"
default=
"true"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/out"
/>
</component>
</project>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/com/roshka/proyectofinal/profesor/EditServlet.java
View file @
0ff36db1
...
...
@@ -17,9 +17,9 @@ public class EditServlet extends HttpServlet {
int
id
=
Integer
.
parseInt
(
request
.
getParameter
(
"id"
));
ProfesorDao
profesorDao
=
new
ProfesorDao
();
Profesor
profesor
=
profesorDao
.
getProfesorById
(
id
);
//
Profesor profesor = profesorDao.getProfesorById(id);
request
.
setAttribute
(
"Profesor"
,
profesor
);
//
request.setAttribute("Profesor", profesor);
RequestDispatcher
rd
=
request
.
getRequestDispatcher
(
"formulario_profesor.jsp"
);
rd
.
include
(
request
,
response
);
}
...
...
@@ -36,13 +36,13 @@ public class EditServlet extends HttpServlet {
Profesor
profesor
=
new
Profesor
(
nro_cedula
,
nombre
,
apellido
,
email
);
profesor
.
setId
(
id
);
int
status
=
ProfesorDao
.
update
(
profesor
);
//
int status=ProfesorDao.update(profesor);
if
(
status
>
0
){
response
.
sendRedirect
(
"formulario_profesor.jsp"
);
}
else
{
System
.
out
.
println
(
"Sorry! unable to update record"
);
}
//
if(status>0){
//
response.sendRedirect("formulario_profesor.jsp");
//
}else{
//
System.out.println("Sorry! unable to update record");
//
}
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/roshka/proyectofinal/profesor/Filtros.java
0 → 100644
View file @
0ff36db1
package
com
.
roshka
.
proyectofinal
.
profesor
;
import
com.roshka.proyectofinal.entity.Profesor
;
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
;
import
static
com
.
roshka
.
proyectofinal
.
profesor
.
ProfesorDao
.
buscarPorNombre
;
import
static
com
.
roshka
.
proyectofinal
.
profesor
.
ProfesorDao
.
listarProfesor
;
@WebServlet
(
"/filtros-profesor"
)
public
class
Filtros
extends
HttpServlet
{
@Override
protected
void
doGet
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
List
<
Profesor
>
profesores
=
listarProfesor
();
String
nombre
=
req
.
getParameter
(
"nombreBuscar"
);
String
apellido
=
req
.
getParameter
(
"apellidoBuscar"
);
System
.
out
.
println
(
nombre
);
System
.
out
.
println
(
apellido
);
if
(
nombre
!=
null
||
apellido
!=
null
){
profesores
=
buscarPorNombre
(
nombre
,
apellido
);
}
req
.
getServletContext
().
setAttribute
(
"profesores"
,
profesores
);
RequestDispatcher
reqDisp
=
req
.
getRequestDispatcher
(
"profesor-consulta.jsp"
);
reqDisp
.
forward
(
req
,
resp
);
}
@Override
protected
void
doPost
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
List
<
Profesor
>
nombre
=
listarProfesor
();
List
<
Profesor
>
apellido
=
listarProfesor
();
req
.
getServletContext
().
setAttribute
(
"nombre"
,
nombre
);
req
.
getServletContext
().
setAttribute
(
"apellido"
,
apellido
);
RequestDispatcher
reqDisp
=
req
.
getRequestDispatcher
(
"profesor-consulta.jsp"
);
reqDisp
.
forward
(
req
,
resp
);
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/roshka/proyectofinal/profesor/ProfesorDao.java
View file @
0ff36db1
package
com
.
roshka
.
proyectofinal
.
profesor
;
import
com.roshka.proyectofinal.DataBase
;
import
com.roshka.proyectofinal.entity.Lenguaje
;
import
com.roshka.proyectofinal.entity.Profesor
;
import
java.sql.Connection
;
...
...
@@ -31,55 +30,54 @@ public class ProfesorDao {
return
status
;
}
public
static
List
<
Profesor
>
listar
(){
public
static
List
<
Profesor
>
listarProfesor
(){
ArrayList
<
Profesor
>
list
=
new
ArrayList
<>();
String
sql
=
"select * from profesor"
;
try
{
Connection
con
=
DataBase
.
getConnection
();
PreparedStatement
ps
=
con
.
prepareStatement
(
sql
);
ResultSet
rs
=
ps
.
executeQuery
();
while
(
rs
.
next
()){
Profesor
profe
=
new
Profesor
();
profe
.
setId
(
rs
.
getInt
(
"id"
));
profe
.
setNombre
(
rs
.
getString
(
"nombre"
));
profe
.
setApellido
(
rs
.
getString
(
"apellido"
));
profe
.
setNro_cedula
(
rs
.
getInt
(
"nro_cedula"
));
profe
.
setCorreo
(
rs
.
getString
(
"correo"
));
list
.
add
(
profe
);
Profesor
profesorObject
=
new
Profesor
();
profesorObject
.
setNombre
(
rs
.
getString
(
"nombre"
));
profesorObject
.
setApellido
(
rs
.
getString
(
"apellido"
));
profesorObject
.
setNro_cedula
(
rs
.
getInt
(
"nro_cedula"
));
profesorObject
.
setCorreo
(
rs
.
getString
(
"correo"
));
list
.
add
(
profesorObject
);
}
con
.
close
();
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
return
list
;
}
public
static
int
update
(
Profesor
p
){
int
status
=
0
;
public
static
List
<
Profesor
>
buscarPorNombre
(
String
nombre
,
String
apellido
){
List
<
Profesor
>
profesores
=
new
ArrayList
<>();
Profesor
profesorObject
=
new
Profesor
()
;
try
{
Connection
con
=
DataBase
.
getConnection
();
PreparedStatement
ps
=
con
.
prepareStatement
(
"update profesor set nombre=?, apellido=?, correo=?, nro_cedula=? where id=?"
);
ps
.
setString
(
1
,
p
.
getNombre
());
ps
.
setString
(
2
,
p
.
getApellido
());
ps
.
setString
(
3
,
p
.
getCorreo
());
ps
.
setInt
(
4
,
p
.
getNro_cedula
());
ps
.
setInt
(
5
,
p
.
getId
());
PreparedStatement
ps
=
con
.
prepareStatement
(
"select a.id, a.nombre, a.apellido, a.nro_cedula, a.correo from profesor a "
+
" where a.nombre ilike ? and a.apellido ilike ? "
);
status
=
ps
.
executeUpdate
();
con
.
close
();
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();}
ps
.
setString
(
1
,
"%"
+
nombre
+
"%"
);
ps
.
setString
(
2
,
"%"
+
apellido
+
"%"
);
System
.
out
.
println
(
nombre
);
ResultSet
rs
=
ps
.
executeQuery
();
while
(
rs
.
next
()){
return
status
;
profesorObject
.
setNombre
(
rs
.
getString
(
"nombre"
));
profesorObject
.
setApellido
(
rs
.
getString
(
"apellido"
));
profesorObject
.
setNro_cedula
(
rs
.
getInt
(
"nro_cedula"
));
profesorObject
.
setCorreo
(
rs
.
getString
(
"correo"
));
profesores
.
add
(
profesorObject
);
}
con
.
close
();
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();
}
return
profesores
;
}
public
static
int
delete
(
int
id
){
int
status
=
0
;
try
{
...
...
@@ -93,25 +91,4 @@ public class ProfesorDao {
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
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/webapp/formulario_profesor.jsp
View file @
0ff36db1
...
...
@@ -11,8 +11,9 @@
</head>
<body>
<div>
<h1>
CREAR PROFESOR
</h1>
<h1>
CREAR PROFESOR
Y FILTRAR
</h1>
<
%@
page
import=
"com.roshka.proyectofinal.entity.Profesor, com.roshka.proyectofinal.profesor.ProfesorDao, java.util.List,java.util.Iterator"
%
>
...
...
@@ -21,7 +22,7 @@
<div>
<
%
ProfesorDao
profeDao =
new
ProfesorDao
();
List
<
Profesor
>
listProfe = profeDao.listar();
List
<
Profesor
>
listProfe = profeDao.listar
Profesor
();
Iterator
<Profesor>
iterProfe = listProfe.iterator();
Profesor profesor = null;
%>
...
...
@@ -52,6 +53,14 @@
</button>
</form>
<br>
<form
action=
"filtros-profesor"
>
<input
name=
"nombreBuscar"
>
<input
name=
"apellidoBuscar"
>
<button
type=
"submit"
>
Filtrar
</button>
</form>
<br>
<table>
<thead>
...
...
This diff is collapsed.
Click to expand it.
src/main/webapp/postulante-consulta.jsp
View file @
0ff36db1
...
...
@@ -45,7 +45,7 @@
</form>
</th>
<th>
<form
action=
"filtros-postulante"
method=
"post"
>
<form
action=
"filtros-pos
j
tulante"
method=
"post"
>
<input
type=
"hidden"
name=
"nombre"
value=
"aceptado"
>
<button
type=
"submit"
>
Aceptado
</button>
</form>
...
...
This diff is collapsed.
Click to expand it.
src/main/webapp/profesor-consulta.jsp
0 → 100644
View file @
0ff36db1
<
%@
page
language=
"java"
contentType=
"text/html; charset=ISO-8859-1"
pageEncoding=
"ISO-8859-1"
%
>
<
%@
taglib
uri =
"http://java.sun.com/jsp/jstl/core"
prefix =
"c"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=ISO-8859-1"
>
<!-- el icono para la pagina -->
<link
rel=
"shortcut icon"
href=
"imagenes/roshkaicon.ico"
sizes=
"any"
/>
<!-- coneccion con el de css -->
<link
rel=
"stylesheet"
href=
"postulante.css"
>
<title>
Profesor MANAGE
</title>
</head>
<body>
<div>
<h1>
LISTA PROFESORES
</h1>
<form
action=
"filtros-profesor"
>
<input
type=
"search"
name=
"nombreBuscar"
placeholder=
"Buscar por nombre"
>
<input
type=
"search"
name=
"apellidoBuscar"
placeholder=
"Buscar por apellido"
>
<button
type=
"submit"
>
Buscar
</button>
</form>
<table>
<tr>
<th>
#
</th>
<th>
Nombre
</th>
<th>
Apellido
</th>
<th>
Numero de Cedula
</th>
<th>
Correo
</th>
<th>
Editar
</th>
<th>
Eliminar
</th>
</tr>
<tbody>
<c:forEach
var=
"profesor"
items=
"${profesores}"
varStatus=
"myIndex"
>
<tr>
<td>
${myIndex.index + 1}-
</td>
<td>
${profesor.nombre}
</td>
<td>
${profesor.apellido}
</td>
<td>
${profesor.nro_cedula}
</td>
<td>
${profesor.correo}
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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