-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.jsp
executable file
·94 lines (80 loc) · 2.63 KB
/
index.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<%@ page import ="operacions.*" %>
<%@ page import="java.sql.*" %>
<%@ page import ="java.util.*" %>
<!--Creo el objeto operacions, hago la conexión y lleno el arraylist de libros -->
<%
String statCon="nada";
OperacionsBiblioLibro operacions=new OperacionsBiblioLibro();
statCon = operacions.abrirConexion();
ArrayList<Libro> datos = new ArrayList<Libro>();
try{
datos = operacions.consultarLibros();
%>
<html>
<head>
<link rel="stylesheet" type="text/css" href="estilos.css" media="screen" />
<title>Gestión Biblioteca</title>
</head>
<body>
<!--Si recibe el parametro borrar, borramos el libro con el id correspondiente -->
<%
if (request.getParameter("borrar")!=null){
operacions.borrarLibro(Integer.parseInt(request.getParameter("borrar")));
%>
<!--Mostramos un alert, y volvemos a la pagina correspondiente-->
<script type="text/javascript" >
alert("Se ha borrado el libro");
location.href = "index.jsp";
</script>
<%
}
%>
<!--Barra de titulo-->
<div class="bar_titulo">
<table class="tabla_titulo">
<tr>
<td colspan="2">
<h3>Gestión de Libros</h3>
</td>
<td>
<a class="boton" href="crearLibro.jsp">Nuevo</a>
</td>
</tr>
</table>
</div>
<section><!--tabla -->
<div id="tabla">
<table border="1" class="tabla_seleccion">
<tr><th scope="col">ID</th><th scope="col">ISBN</th><th scope="col">Título</th><th scope="col">Autores</th><th scope="col">Ano</th><th scope="col">Accións</th><th scope="col">Eliminar</th></tr>
<!--Recorremos el arraylist y vamos metiendo filas en la tabla -->
<%
for (int i=0; i<datos.size(); i++){
%>
<tr>
<td><%=datos.get(i).getIdLibro()%></td>
<td><%=datos.get(i).getISBN()%></td>
<td><%=datos.get(i).getTitulo()%></td>
<td><%=datos.get(i).getAutores()%></td>
<td><%=datos.get(i).getAno()%></td>
<td><a class="boton" href="consultarLibro.jsp?id=<%=datos.get(i).getIdLibro()%>">Consultar</a>
<a class="boton" href="modificarLibro.jsp?id=<%=datos.get(i).getIdLibro()%>">Modificar</a></td>
<td><a class="boton boton_rojo" href="index.jsp?borrar=<%=datos.get(i).getIdLibro()%>">Borrar</a></td></tr>
<!--Cerramos la conexión, y manejamos la excepción -->
<%
}
operacions.cerrarConexion();
}catch(Exception e){
out.println("Error"+e.getMessage());
}
%>
</table>
</div>
</section><!--Fin tabla -->
</body>
<!--Muestro los errores con getErro en el pie de la pagina-->
<footer class="pie"><!--Pie-->
<div >
<span>JDBC version:<%=statCon%> ||</span><span style="color:#FF0000">Consola: <%=operacions.getErro()%></span>
</div>
</footer>
</html>