title: How to set/get values of checkboxes from a servlet dynamically
body: <p>This is more of a logic question. I have a checkbox on a webpage and I store its value from the servlet request parameters in a Boolean object (Java). The logic is, if the request parameter for the checkbox is not null, make the object true, otherwise it's null. When the page is called again, it marks the checkbox as "checked" if its stored value is true. </p>
  
  <pre><code>this.checkbox = (servlet.getParameter("checkbox")!=null &amp;&amp; servlet.getParameter("checkbox").contentEquals("on"))?true:null;
  </code></pre>
  
  <p>The problem starts when I persist that checkbox object. I first populate the page with the persisted data and then fill it with the servlet values. If the checkbox value is stored as true in the database, and the user unchecks it on the page and submits it, since the servlet parameter for the checkbox becomes null, I am unable to make the checkbox null. So the checkbox always show the persisted value since its never gets overwritten. So can anyone suggest some logic change in how I am filling the object value? </p>