I have a jsp file called display.jsp. I written this code and I am getting the result as you seeing the snapshot, where its displaying all the user_details what I have in the database. Also I have edit button. So my query is, if I click the edit button on a particular user, I need to get a form showing all the textfields like firstname, lastname, dob, address, username, password that should be pre-filled in the textfields fetching from Display.jsp.
Here is the code for Display.jsp:
<%@ page import="java.sql.*" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login Details</title>
</head>
<body>
<body bgcolor="Yellow">
<form method="GET" id="my_form"></form>
<table border="1" width="50%" height="30%">
<tr>
<th><font color='Red'>FirstName</font></th>
<th><font color='Red'>LastName</font></th>
<th><font color='Red'>DOB</font></th>
<th><font color='Red'>Address</font></th>
<th><font color='Red'>UserName</font></th>
<th><font color='Red'>Password</font></th>
</tr>
<%
Class.forName("com.mysql.jdbc.Driver");
Connectioncon=DriverManager.getConnection("jdbc:mysql://localhost:3306 /","root","scott");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select *from come2links.user_details");
while(rs.next())
{
String FisrtName=rs.getString("FirstName");
String LastName=rs.getString("LastName");
Date dob = rs.getDate("DOB");
String address=rs.getString("Address");
String UserName=rs.getString("UserName");
String Password=rs.getString("Password");
%>
<tr>
<td><b><font color='#663300'><%=FisrtName%></font></b></td>
<td><b><font color='#663300'><%=LastName%></font></b></td>
<td><b><font color='#663300'><%=dob%></font></b></td>
<td><b><font color='#663300'><%=address%></font></b></td>
<td><b><font color='#663300'><%=UserName%></font></b></td>
<td><b><font color='#663300'><%=Password%></font></b></td>
<td>
<form name="f1" action="Update.jsp" >
<input id="edit1" type="submit" value="Edit">
</form>
<%
}
%>
</tr>
</table>
</body>
</html>