title: How to set the value of a check box dynamically in jsp (values are coming from database)
body: <p>I have a <code>jsp</code> file in which i have to display the notes with there date and description
  Since there can be more than one note(as in a scheduler) for a particular date so more than one notes are displayed at a time. Now i want that user can modify particular notes in the database by checking them with the help of check boxes. now as the values of note are coming dynamically from the data base how can i set the value for check box.</p>
  
  <p><strong>fetchcontent.java</strong></p>
  
  <pre><code>public class CnmsDes extends HttpServlet{
      public void doPost.......{
          List list=new ArrayList();
          response.setContentType("text/html");
          PrintWriter out = response.getWriter();
          System.out.println("Oracle Connect Example.");
          Connection conn = null;
          String url = "jdbc:oracle:thin:@localhost:1521:xe";
          String driver = "oracle.jdbc.driver.OracleDriver";
          String userName = "system"; 
          String password = "mint";
          Statement st;
          try {
              Class.forName(driver).newInstance();
              conn = DriverManager.getConnection(url,userName,password);
              System.out.println("Connected to the database");
  
              String  ndate  = request.getParameter("date");
              String  eid  = request.getParameter("empid");
              String strar[] = ndate.split("/");
              String cdate = strar[0]+"/" + strar[1]+"/"+ strar[2];
              if(eid==null||eid=="Enter Your Employee ID"){response.sendRedirect("viewnotes.jsp");}
              String query = "select * from CNMS_NOTES where emp_id='"+eid+"' and note_date='"+cdate+"'";
  
              Statement stmt=conn.createStatement();
              ResultSet rs=stmt.executeQuery(query);
  
  
              while(rs.next()){
                  list.add(rs.getString("note_date"));
                  list.add(rs.getString("title"));
                  list.add(rs.getString("description"));
  
              }
  
          }
          catch(Exception e){out.print(e);}
          request.setAttribute("description",list);
          RequestDispatcher rd = request.getRequestDispatcher("/displaynotes.jsp");
          rd.forward(request, response);
      } 
  }
  </code></pre>
  
  <p>and <strong>displaynotes.jsp</strong></p>
  
  <pre><code>&lt;%@page language="java" import="java.util.*" %&gt;
  &lt;html&gt;
      &lt;body background="images/bg1.jpg"&gt;     
          &lt;form&gt;
              &lt;table class="t" border="1" width="650" align="center" &gt;
                  &lt;tr&gt;
                      &lt;td width="10"&gt;&lt;b&gt;&lt;/b&gt;&lt;/td&gt;
                      &lt;td width="100"&gt;&lt;b&gt;Date&lt;/b&gt;&lt;/td&gt;
                      &lt;td width="150"&gt;&lt;b&gt;Title&lt;/b&gt;&lt;/td&gt;
                      &lt;td width="100"&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/td&gt;            
                  &lt;/tr&gt;
  
                  &lt;%  
                      Iterator itr;
                      List data=(List)request.getAttribute("description");            
                      int k=data.size();
                      request.setAttribute("size",k);        
                      for(itr=data.iterator();itr.hasNext();) {
                  %&gt;
  
                  &lt;tr class="a"&gt;          
                      &lt;td&gt;
                          &lt;input type="checkbox" name="cbdate" value="&lt;%=request.getParameter("checkeddate") %&gt;"&gt;
                      &lt;/td&gt;
                      &lt;td width="100"&gt;
                          &lt;input type="text" name="checkeddate" value="&lt;%=itr.next()%&gt;" class="b"&gt;
                      &lt;/td&gt;
                      &lt;td width="150"&gt;
                          &lt;input type="text" name="checkedtitle" value="&lt;%=itr.next()%&gt;" class="b"&gt;
                      &lt;/td&gt;
                      &lt;td width="200"&gt;
                          &lt;textarea cols="39" rows="3"&gt;&lt;%=itr.next()%&gt;&lt;/textarea&gt;
                      &lt;/td&gt;        
                  &lt;/tr&gt;
                  &lt;% } %&gt;
              &lt;/table&gt;
              &lt;table border="1" align="center"&gt;
                  &lt;tr&gt;
                      &lt;td&gt;
                          &lt;input type="submit" value="MODIFY" onclick="this.form.action='expriment.jsp';"&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;input type="submit" value="DELETE" onclick="this.form.action='abc.jsp';"&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>