how to edit only one row from multiple row from single jsp page dynamically
<%@ page language="java" import="java.sql.*"%>
<head>
</head>
<body bgcolor="#008B8B">
<form name="editform" method="post" >
<br><br><br>
<%
String id = request.getParameter("id");
String name = request.getParameter("name");
String username = request.getParameter("username");
String password = request.getParameter("password");
String company_id = request.getParameter("company_id");
String company_name = request.getParameter("company_name");
String address = request.getParameter("address");
String phone = request.getParameter("phone");
String fax = request.getParameter("fax");
String email_id = request.getParameter("email_id");
%>
<table align="center" width="300px" style="background-color:#EDF6EA;border:1px solid #000000;">
<tr><td colspan=2 style="font-weight:bold;" align="center">Edit User</td></tr>
<tr><td colspan=2 align="center" height="10px"></td></tr>
<tr>
<td>id</td>
<td><input type="text" name="id" value="<%=id%>"></td>
</tr>
<tr>
<td>name</td>
<td><input type="text" name="name" value="<%=name%>"></td>
</tr>
<tr>
<td>username</td>
<td><input type="text" name="username" value="<%=username%>"></td>
</tr>
<tr>
<td>password</td>
<td><input type="text" name="password" value="<%=password%>"></td>
</tr>
<tr>
<td>company_id</td>
<td><input type="text" name="company_id" value="<%=company_id%>"></td>
</tr>
<tr>
<td>company_name</td>
<td><input type="text" name="company_name" value="<%=company_name%>"></td>
</tr>
<tr>
<td>address</td>
<td><input type="text" name="address" value="<%=address%>"></td>
</tr>
<tr>
<td>phone</td>
<td><input type="text" name="phone" value="<%=phone%>"></td>
</tr>
<tr>
<td>fax</td>
<td><input type="text" name="fax" value="<%=fax%>"></td>
</tr>
<tr>
<td>email_id</td>
<td><input type="text" name="email_id" value="<%=email_id%>"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="Update" style="background-color:#49743D;font-weight:bold;color:#ffffff;"></td>
</tr>
<tr><td colspan=2 align="center" height="10px"></td></tr>
</table>
<%
Statement stmt;
Connection conn = null;
out.println(request.getRequestURI());
if (id != null && name != null && username != null && password != null && company_id != null && company_name != null && address != null && phone != null && fax != null && email_id != null)
{
if (id != "" && name != "" && username != "" && password != "" && company_id != "" && company_name != "" && address != "" && phone != "" && fax != "" && email_id != "" ) {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/company","root","root");
String query = "UPDATE addcmp SET id= "+id+",name=" + name + ",username=" + username + ",password=" + password + ",company_id=" + company_id + ",company_name=" + company_name + ", address=" + address + ", phone=" + phone + ", fax=" + fax + ", email_id=" + email_id + "";
stmt = conn.createStatement();
int i = stmt.executeUpdate(query);
System.out.println("query" + query);
if (i > 0)
{ System.out.println("Connected to the database");
response.sendRedirect("Edit.jsp");
}
conn.close();
System.out.println("Disconnected from database");
%>
<br>
<TABLE style="background-color: #E3E4FA;"
WIDTH="30%" border="1">
<tr><th>Data Modified successfully in database.</th></tr>
</TABLE>
<%
} catch (Exception e) {
e.printStackTrace();
}
}
}
%>
</form>
</body>
</html>