You are on page 1of 6

Video de la ejecución del programa:

https://www.youtube.com/watch?
v=9p_HvUVvXWw&feature=youtu.be

Código del programa:

<%@page import="java.sql.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1 align="center" >LISTADO DE USUARIOS</h1>

<TABLE BORDER="1" WIDTH="600"align="center">


<tr>

<th colspan="5">Mantenimiento de usuarios</th>


<th><a href="1969648.jsp">
<img src="iconos/1969648.png" width="50" height="50" ></a></th>
</tr>

<TR BGCOLOR="RED ">


<TH>CODIGO</th><th>NOMBRE</TH><TH>EDAD</TH>
<TH>SEXO</TH><TH>CONTRASEÑA</TH><TH>Accion</TH>
</TR>

<%
Connection cnx=null;
Statement sta=null;
ResultSet rs=null;

try{
Class.forName("com.mysql.jdbc.Driver");
cnx=DriverManager.getConnection("jdbc:mysql://localhost/cursojsp?
user=root&password=");

sta=cnx.createStatement();
rs=sta.executeQuery("select * from usuarios");
while(rs.next()){

%>
<tr>
<th><%=rs.getString(1)%></th>
<th><%=rs.getString(2)%></th>
<th><%=rs.getString(3)%></th>
<th><%=rs.getString(4)%></th>
<th><%=rs.getString(5)%></th>
<th>

<img src="iconos/descarga.png" width="30" height="30"> //


<img src="iconos/88666.png" width="30" height="30">
</th>
</tr>
<%

}
sta.close();
rs.close();
cnx.close();

}catch(Exception e){}

%>
</TABLE>
</body>
</html>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="com.mysql.jdbc.Statement"%>
<%@page import="java.sql.ResultSet"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h2 align="center">RESGISTRO DE USUARIOS</H2>
<form action="">
<table border="50" width="250" align="CENTER">
<tr>
<td>CODIGO: </td>
<td><input type="text" name="txtCod"></td>
</tr>
<tr>
<td>NOMBRE:</td>
<td><input type="text" name="txtNom"></td>
</tr>
<tr>
<td>EDAD:</td>
<td><input type="text" name="txtEdad"></td>
</tr>
<tr>
<td>SEXO:</td>
<td><input type="text" name="txtSexo"></td>
</tr>
<tr>
<td>CONTRASEÑA:</td>
<td><input type="text" name="txtCON"></td>
</tr>
<tr>

<TH COLPS="2">
<input type='submit'name='btngrabar'
value='Grabar usuario'></td>
</tr>

</table>
</form>
<%
String cod=request.getParameter("txtCod");
String nom=request.getParameter("txtCNom");
int edad=Integer.parseInt(request.getParameter("txtEdad"));
String sexo=request.getParameter("txtSexo");
String Contraseña=request.getParameter("txtCon");

Connection cnx=null;
ResultSet rs=null;
Statement sta=null;
try{
Class.forName("com.mysql.jdbc.Driver");
cnx=DriverManager.getConnection
("jdbc:mysql://localhost/cursojsp?user=root&password=");

}catch(Exception e){}

%>
</body>
</html>

You might also like