title: Populating checkboxes in JSP page with data from a JavaBean
body: <p>I have a JSP page with checkboxes inside an HTML form as below</p>
  
  <p><img src="https://i.stack.imgur.com/Ftsbx.jpg" alt="enter image description here"></p>
  
  <p>Now while editing user <em>Skill</em> I want to take the comma separated values from the table and populate the checkboxes in JSP. The following code brings the CSV Skills from the database table.</p>
  
  <pre><code>      List&lt;UserDetails&gt; Skills = new ArrayList&lt;UserDetails&gt;();
  
        pstmt = (PreparedStatement) conn.prepareStatement(strSQL);
        rs    = pstmt.executeQuery();       
        String strSkills = rs.getString("Skills");
  
        List&lt;String&gt; items = Arrays.asList(strSkills.split("\\s*,\\s*"));
  
        objUserDetails.setSkills(items.toArray(new String[0]));
  
        Skills.add(objUserDetails);
  
        return Skills;
  </code></pre>
  
  <p>Now I need to populate the checkboxes in JSP with the respective Skills checked. I used the Request <code>getAttribute()</code> method and I am passing to JSP as below</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
  {
     dbUtil objdbUtil     = new dbUtil();
     List&lt;UserDetails&gt; Skills = objdbUtil.getSkills();
  
     request.setAttribute("arrSkills", Skills);
     RequestDispatcher rqst = request.getRequestDispatcher("Skills.jsp");
     rqst.forward(request, response);
  }
  </code></pre>
  
  <p>How to use the Skills which I got in arrSkills array and populate the check boxes. I tried using </p>
  
  <pre><code>&lt;c:forEach var="account" items="${arrUsersList}"&gt;
      &lt;input type="checkbox" name="chkSkills" id="chkPHP" value="PHP"/&gt;PHP
      &lt;input type="checkbox" name="chkSkills" id="chkJava" value="Java"/&gt;Java
      &lt;input type="checkbox" name="chkSkills" id="chkMySQL" value="MySQL"/&gt;MySQL
      &lt;input type="checkbox" name="chkSkills" id="chkJavascript" value="Javascript"/&gt;Javascript
      &lt;input type="checkbox" name="chkSkills" id="chkJQuery" value="JQuery"/&gt;JQuery
      &lt;input type="checkbox" name="chkSkills" id="chkNode" value="Node"/&gt;Node Js
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>But I am sure this is not the right way to use it.</p>