title: Null pointer exception in passing checkbox value
body: <p>I made an index page in which you take the value of checkbox and pass it on to a file named AddToWork.java but it is showing null pointer exception. There is some problem in passing the value of the checkbox. Kindly help. Here is the code snipped for index page</p>
  
  <pre><code>&lt;td&gt;
  &lt;center&gt;
  &lt;form action="addtowork?id2=&lt;%=mail.getTempToken()%&gt;" method="post"&gt;
  &lt;input type="submit" value="Add to my work"&gt;
  &lt;input type="checkbox" name="flag" value="flag"&gt;High Priority&lt;/form&gt;   
  &lt;/center&gt;&lt;/td&gt;
  </code></pre>
  
  <p>for AddToWork.java</p>
  
  <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse     response) throws ServletException, IOException {
  
      EmailDesc mail = new EmailDesc();
  
      String imp = new String();
  
      imp = (String) request.getParameter("flag");
  
  
  
      String thisid = request.getParameter("id2");
      Home home = new Home();
  
      User user = new User();
  
      user = (User) request.getSession().getAttribute("user");
  
      mail = home.getEmail(thisid, user);
  
  
  
      home.givePermanentToken(mail,thisid);
  
      if (imp.equals("flag")){
          System.out.println("Priority Changed to " + mail.getPriority() + "!");
      }
  
  
  
      response.sendRedirect("index1.jsp");
  
  
  
  }
  </code></pre>
  
  <p>If I remove the if statement in addtowork.java, the code runs perfectly.</p>