Professional Documents
Culture Documents
https://www.youtube.com/watch?
v=9p_HvUVvXWw&feature=youtu.be
<%@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>
<%
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>
}
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"%>
<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>