//this some code i have written on jsp page named (ShowClientDetails.jsp)
here i have a checkbox named(checkit)
data in the text field is comming from servlet page using backend mysql database
//
<form name="showclient" action="/LotteryProject/jsp/ShowClientDetails.jsp" method="post"><table width="" border="0" cellspacing="0" cellpadding="0">
<tr>
<th style="color: white">Client ID</th>
<th style="color: white">First Name</th>
<th style="color: white">Last Name</th>
<th style="color: white">Password</th>
<th style="color: white">Amount Provided</th>
<th style="color: white">Status</th>
<th style="color: white">Check</th>
</tr>
<% Iterator itr;%>
<% List data= (List)request.getAttribute("clientinfo");
for (itr=data.iterator();itr.hasNext()
{
%>
<tr>
<td><input type="text" name="clientid" value="<%=itr.next()%>" readonly /></td>
<td><input type="text" name="firstname" value="<%=itr.next()%>" readonly/></td>
<td><input type="text" name="lastname" value="<%=itr.next()%>" readonly/></td>
<td><input type="text" name="password" value="<%=itr.next()%>" readonly/></td>
<td><input type="text" name="amountprovided" value="<%=itr.next()%>" readonly/></td>
<td><input type="text" name="status" value="<%=itr.next()%>" readonly/></td>
<td><input type="checkbox" name="checkit" ></td>
</tr>
<% }%>
<tr>
<td colspan="7" align="center"><input type="submit" name="submit" value="Submit" /></td>
</tr>
</table>
</form>
.................................................. .................................................. ..............................
// our servlet looks like
//name of servlet is MyServlet
package mypack;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpSession;
/**
*
* @author KUNDAN
*/
public class MyServlet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String username="";
String userpass="";
Connection conn=null;
ResultSet rs,rs1,rs2=null;
PreparedStatement st,st1,st2,st3,st4;
HttpSession session=request.getSession(false);
List dataList=new ArrayList();
try{
Class.forName("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/LotteryDb","root","root");
String str10=request.getParameter("adm").toString();
String str11="adm";
if(str10.equals(str11))
{
st4 = conn.prepareStatement("select * from clientinfo");
rs2=st4.executeQuery();
while(rs2.next())
{
dataList.add(rs2.getInt("client_id"));
dataList.add(rs2.getString("firstname"));
dataList.add(rs2.getString("lastname"));
dataList.add(rs2.getString("password"));
dataList.add(rs2.getString("amountprovided"));
dataList.add(rs2.getString("status"));
}
request.setAttribute("clientinfo", dataList);
RequestDispatcher dispatcher=request.getRequestDispatcher("/jsp/ShowClientDetails.jsp");
dispatcher.forward(request, response);
}
}catch(Exception e)
{
e.getMessage();
}
} finally {
out.close();
}
.................................................. .................................................. ..............................
// my problem is that i want to change the value of textbox named (status) after selecting check box
and clicking submit button
and this changed value further i want to pass it to servlet page that i have all ready created.
please can any one help me ?????????????????
tanks in advance.......................